Skip to Main Content Skip to Search
Product Documentation

NET.convertArray - Package: NET

Convert numeric MATLAB array to .NET array

Syntax

arrObj = NET.convertArray(V,'arrType',[m,n])

Description

arrObj = NET.convertArray(V,'arrType',[m,n]) converts a MATLAB array V to a .NET array. Optional value arrType is a string representing a namespace-qualified .NET array type. Use optional values m,n to convert a MATLAB vector to a two-dimensional .NET array (either 1-by-n or m-by-1). If V is a MATLAB vector and you do not specify the number of dimensions and their sizes, the output arrObj is a one-dimensional .NET array.

If you do not specify arrType, MATLAB converts the type according to the MATLAB Primitive Type Conversion Table.

Examples

Create a list aList of random System.Int32 integers using the System.Collections.Generic.List class, and then sort the results:

%Create array R of random integers
nInt = 5;
R = randi(100,1,nInt);
%Create .NET array A
A = NET.convertArray(R,'System.Int32');
%Put A into aList, a generic collections list
aList = NET.createGeneric(...
    'System.Collections.Generic.List',...
    {'System.Int32'},A.Length);
aList.AddRange(A);
%Sort the values in aList
aList.Sort;

See Also

NET.createArray

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS