The MATLAB® data types are incompatible with native .NET types. To send data between your application and .NET, you perform these tasks:
Marshal data from .NET input data to a deployed function
by creating an
MWArray object from native .NET
public functions in a deployed component
Marshal the output MATLAB data in an
native .NET data by calling one of the
ToArray(), for example).
Manual Data Marshaling Without a Type-Safe Interface
As you can see, manually marshaling data adds complexity and potential failure points to the task of integrating deployed components into a .NET application. This is particularly true for these reasons:
Your application cannot detect
type mismatch errors until run time. For example, you might
accidentally create an
MWArray from a string and
pass the array to a deployed function that expects a number. Because
the wrapper code generated by MATLAB
Compiler SDK™ expects an
the .NET compiler is unable to detect this error and the deployed
function either throws an exception or returns the wrong answer.
Your end users must learn how
to use the
MWArray data type or alternately
MWArray data type behind a manually written
(and manually maintained) API. This introduces unwanted training time
and places resource demands on a potentially overcommitted staff.
You can avoid performing
MWArray data marshaling
by using type-safe interfaces. Such interfaces
minimize explicit type conversions by hiding the
from the calling application. Using type-safe interfaces allows .NET
developers to work directly with familiar native data types. For more
information, see Implement a Type-Safe Interface.
Simplified Data Marshaling With a Type-Safe Interface