Convert Nested System.Object Arrays

This example shows how to use the cell function to convert data in nested System.Object arrays.

The conversion is not recursive for a System.Object array contained within a System.Object array. Use the cell function to convert each System.Object array.

The C# example NetDocCell.cs, in the matlabroot/extern/examples/NET/NetSample folder, is used in the following example. To see the code, open the fileopen the file in MATLAB® Editor and build the NetDocCell assembly.

Set up the path to your assembly, then load the assembly.

dllPath = fullfile('c:','work','NetDocCell.dll');

Create a cell array, mlData.

j = NetDocCell.MyGraph;
mlData = cell(obj.getNewData)
mlData = 
    [1x1 System.String]    [1x1 System.Object[]]

To access the contents of the System.Object array, create another cell array mlPlotData.

mlPlotData = cell(mlData{2})
mlPlotData = 
    [1x1 System.String]    [1x1 System.Double[]]

Related Examples

More About

Was this topic helpful?