To support data conversion between managed .NET types and MATLAB® types, MATLAB
Compiler SDK™ provides a set of data conversion classes derived from the abstract class
MWArray. These classes allow you to pass most native .NET value types
as parameters directly without using explicit data conversion. You reference the
MWArray assembly in your managed application to convert native arrays
to MATLAB arrays and vice versa. This process is called data
When you invoke a method on a component, the input and output parameters are a derived
MWArray. To pass parameters, you can either instantiate one of
MWArray subclasses explicitly, or, in many cases, pass the parameters
as a managed data type and rely on the implicit data conversion
feature of MATLAB
For examples that demonstrate guidelines for manual data conversion between various native data types and types compatible with MATLAB, see Convert Data Between .NET and MATLAB.
MWArray data conversion classes are built as a class hierarchy
that represents the major MATLAB array types.
The root of the hierarchy is the
MWArray abstract class.
MWIndexArray is also an abstract class. The other subclasses
represent the major MATLAB array types:
MWArray and its derived classes provide the following
Constructors and destructors to instantiate and dispose of MATLAB arrays
Properties to get and set the underlying array data
Indexers to support a subset of MATLAB array indexing
Implicit and explicit data conversion operators
For information about these data conversion classes, see the
MWArray Class Library Reference, which is also available in
matlabroot represents your MATLAB installation folder.
In most instances, if you use a native .NET primitive or array as an input parameter
in a C# program, MATLAB
Compiler SDK automatically and transparently converts it to an instance of the
MWArray class before passing it to the generated method.
Compiler SDK converts most CLS-compliant strings, numeric types, or multidimensional
arrays of these types to an appropriate
MWArray type. For a list of the
unsupported types, see Unsupported MATLAB Array Types. This conversion is transparent in C# applications, but might
require an explicit casting operator in other languages, for example,
in Visual Basic®.
For example, consider the .NET statement:
result = theFourier.plotfft(3, data, interval);
In this statement, the argument
interval is of the .NET native type
Compiler SDK casts this argument to a MATLAB 1-by-1 double
MWNumericArray type, which is a wrapper
class containing a MATLAB double array.
All data returned from a MATLAB function to a .NET method is represented as an instance of the appropriate
MWArray subclass. For example, a MATLAB cell array is returned as an
Returned data is not automatically converted to a native array.
If you need to get the corresponding native array type, call the
ToArray method, which converts a MATLAB array to the appropriate native data type, with some exceptions. Cell
arrays, structure arrays, and arrays of complex numbers are not available as native .NET
types. To represent these data types, you must create an instance of
For a list of the .NET native data types and their equivalents in MATLAB, see Rules for Data Conversion Between .NET and MATLAB.