Main Content

Convert Nested System.Object Arrays

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

The conversion of .NET arrays to cell arrays 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 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');
NET.addAssembly(dllPath);

Create a cell array, mlData.

graph = NetDocCell.MyGraph;
mldata = cell(graph.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