MATLAB Help Center
Array for nonprimitive .NET types
array = NET.createArray(typeName,[m,n,p,...])
array = NET.createArray(typeName,m,n,p,...)
array = NET.createArray(typeName,[m,n,p,...]) creates a multidimensional .NET array of type typeName.
typeName
m,n,p,...
array
example
array = NET.createArray(typeName,m,n,p,...) is an alternative syntax for creating an array.
You cannot specify the lower bound of an array.
collapse all
Create a .NET array of List<Int32> generic type.
List<Int32>
genType = NET.GenericClass('System.Collections.Generic.List','System.Int32'); arr = NET.createArray(genType,5)
arr = List<System*Int32>[] with properties: Length: 5 LongLength: 5 Rank: 1 SyncRoot: [1x1 System.Collections.Generic.List<System*Int32>[]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
Create a .NET array of three elements.
jaggedArray = NET.createArray('System.Double[]',3)
jaggedArray = Double[][] with properties Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1x1 System.Double[][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
Assign values to arrays of different dimensions.
jaggedArray(1) = [1,3,5,7,9]; jaggedArray(2) = [0,2,4,6]; jaggedArray(3) = [11,22];
Display the first value of the third array.
jaggedArray(3,1)
ans = 11
Create a jagged array of List<Double> generic type.
List<Double>
Define the generic type.
genCls = NET.GenericClass('System.Collections.Generic.List[]','System.Double');
Create the array.
genArr = NET.createArray(genCls,3)
genArr = List<System*Double>[][] with properties: Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1×1 System.Collections.Generic.List<System*Double>[][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
Create a jagged array of type System.Double[][][].
System.Double[][][]
netArr = NET.createArray('System.Double[][]',3)
netArr = Double[][][] with properties: Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1x1 System.Double[][][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
NET.GenericClass
Fully specified .NET array type name, specified as a string, character vector, or NET.GenericClass object.
Example: 'System.Double[]'
'System.Double[]'
Example: 'NET.GenericClass('System.Collections.Generic.List','System.Int32')'
'NET.GenericClass('System.Collections.Generic.List','System.Int32')'
Number of elements in each dimension, specified as an array of integers.
Introduced in R2009a
NET.convertArray | NET.createGeneric
NET.convertArray
NET.createGeneric
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office