In Java®, there is no direct representation available for MATLAB® struct arrays and cell arrays.
As a result, when an instance of MWStructArray
or MWCellArray
is
converted to a Java native type using the toArray()
method,
the output is a multi-dimensional Object
array
which can be difficult to process.
When you use MATLAB
Compiler SDK™ packages with RMI, however,
you have control over how the server sends the results of MATLAB function
calls back to the client. The server can be set to marshal the output
to the client as an MWArray
(com.mathworks.toolbox.javabuilder
package)
sub-type or as a Java native data type. The Java native
data type representation of MWArray
subtypes is
obtained by invoking the toArray()
method by the
server.
Using Java native representations of MATLAB struct and cell arrays is recommended if both of these are true:
You have MATLAB functions on a server with MATLAB struct or cell data types as inputs or outputs
You do not want or need to install MATLAB Runtime on your client machines
The classes in the com.mathworks.extern.java
package
(in javabuilder.jar
) do not need a MATLAB Runtime.
The names of the classes in this package are the same as those in com.mathworks.toolbox.javabuilder
—
allowing the end-user to easily create instances of com.mathworks.extern.java.MWStructArray
or com.mathworks.extern.java.MWCellArray
that
work the same as the like-named classes in com.mathworks.toolbox.javabuilder
—
on a machine that does not have a MATLAB Runtime.
The availability of a MATLAB Runtime on the client machine
dictates how the server should be set for marshaling MATLAB functions,
since the MWArray
class hierarchy can be used only
with a MATLAB Runtime. If the client machine does not have a MATLAB Runtime available,
the server returns the output of toArray()
for
cell or struct arrays as instances of com.mathworks.extern.java.MWStructArray
or com.mathworks.extern.java.MWCellArray
.