Main Content

com.mathworks.matlab.types.CellStr

Javaclass to representMATLABcell array ofcharvectors

Description

TheCellStrclass provides support for passing data from Java®to MATLAB®as a MATLAB cell array ofcharvectors (called acellstrin MATLAB, seecellstr). There are MATLAB functions that require cell arrays ofcharvectors as inputs. To pass arguments from Java to a MATLAB function requiringcellstinputs, use the JavaCellStrclass to create a compatible type.

A MATLABcellstris mapped to a Java圣ringarray.

Creation

CellStr(Object stringArray)creates aCellStrusing a圣ringor圣ringarray. The圣ringarray can have multiple dimensions.

Methods

Public Methods

Object getStringArray()

Get the圣ringor圣ringarray used to create theCellStr.

boolean equals(CellStr1,CellStr2)

Compare oneCellStrinstance with another. TwoCellStrinstances are equal if the圣ringor圣ringarray they contain are the same.

Examples

expand all

  • Construct aCellStrnamedkeySetand put 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(); } }
  • 创建一个CellStrarray and pass it to the MATLABplotfunction to change the appearance of the graph produced by MATLAB. The call to the MATLABprintfunction exports the figure as ajpegfile namedmyPlot.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(); } }
Introduced in R2016b