Package: com.mathworks.matlab.types
Java class to represent MATLAB cell
array of char
vectors
The CellStr
class provides support for passing
data from Java® to MATLAB® as a MATLAB cell array of char
vectors (called a cellstr
in MATLAB,
see cellstr
). There are MATLAB functions
that require cell arrays of char
vectors as inputs.
To pass arguments from Java to a MATLAB function requiring cellst
inputs,
use the Java CellStr
class to create a compatible
type.
A MATLAB cellstr
is mapped to a Java String
array.
CellStr(Object
stringArray)
creates a CellStr
using
a String
or String
array. The String
array
can have multiple dimensions.
| Get the |
| Compare one |
CellStr
This example constructs a CellStr
named keySet
and
puts the variable in the MATLAB base workspace.
import com.mathworks.engine.*; import com.mathworks.matlab.types.*; class javaCellstr { public static void main(String[] args) throws Exception { MatlabEngine eng = MatlabEngine.startMatlab(); CellStr keySet = new CellStr(new String[]{"Jan","Feb","Mar","Apr"}); eng.putVariable("mapKeys",keySet); eng.close(); } }
CellStr
ArrayThis example creates a CellStr
array and
passes it to the MATLAB plot
function
to change the appearance of the graph produced by MATLAB. The
call to the MATLAB print
function
exports the figure as a jpeg
file named myPlot.jpg
.
import com.mathworks.engine.*; import com.mathworks.matlab.types.*; class CellStrArray { public static void main(String[] args) throws Exception { MatlabEngine eng = MatlabEngine.startMatlab(); String[][] strArray = new String[2][2]; strArray[0][0] = "MarkerFaceColor"; strArray[0][1] = "MarkerEdgeColor"; strArray[1][0] = "green"; strArray[1][1] = "red"; CellStr markerCellStr = new CellStr(strArray); eng.putVariable("M",markerCellStr); eng.eval("plot(1:10,'--bs',M{:})"); eng.eval("print('myPlot','-djpeg')"); eng.close(); } }
com.mathworks.matlab.types.Complex
| com.mathworks.matlab.types.HandleObject
| com.mathworks.matlab.types.Struct