Question

I'm trying to do a proof of concept with MATLAB objects. I want to see if you can use MATLAB objects like the one below in Java code. We need the MATLAB objects to keep state. I've used MATLAB Builder JA to create functions in MATLAB and access them in Java, but I'm not sure if MATLAB classes can be sent the same way.

classdef TestObject < handle
  properties (SetAccess = private)
      number = 0;
  end

  methods

      function addToNumber(TO, x)

          TO.number = TO.number + x;
      end
  end
end % classdef
Was it helpful?

Solution

I believe you currently can't do this. You can use MATLAB objects, but if you want to call their methods you need to create a functional wrapper for them, and they won't keep state between calls.

I think I'm right in saying that with Builder for .NET, rather than for Java, you have the ability to pass a .NET object across the boundary to MATLAB, a functionality which you can use to keep whatever state you would have done with a MATLAB object. You might be able to do something similar with a Java object using Builder for JA, but I've never tried it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top