Interfaces Generated by MATLAB Compiler SDK
MATLAB® Compiler SDK™ generates one or more APIs for each MATLAB function in the .NET assembly based on the MATLAB function signature.
A single output signature that assumes that only a single output is required and returns the result in a single
MWArray
rather than an array ofMWArray
.A standard signature that specifies inputs of type
MWArray
and returns values as an array ofMWArray
.A feval signature that includes both input and output arguments in the argument list rather than returning outputs as a return value. Output arguments are specified first, followed by the input arguments.
Single Output API
For each MATLAB function in the .NET assembly, MATLAB
Compiler SDK generates a wrapper class that has overloaded methods to implement the
various forms of the generic MATLAB function call. The single output API for a MATLAB function returns a single MWArray
.
Typically, you use the single output interface for MATLAB functions that return a single argument. You can also use the single output interface when you want to use the output of a function as the input to another function.
The following table shows a generic function foo
along with the
single output API that the compiler generates for its several forms.
Generic MATLAB function |
function [Out1, Out2, ..., varargout] = foo(In1, In2, ..., InN, varargin) |
API if there are no input arguments |
public MWArray foo() |
API if there are one or more input arguments |
public MWArray foo(MWArray In1, |
API if there are optional input arguments |
public MWArray foo(MWArray In1, MWArray In2, ..., |
In the example, the input arguments In1, In2
, and
inN
are of type MWArray
.
Similarly, in the case of optional arguments, the params
arguments
are of type MWArray
. (The varargin
argument is
similar to the varargin
function in MATLAB — it allows the user to pass a variable number of arguments.)
Note
When you call a class method in your .NET application, specify all required inputs first, followed by any optional arguments.
Functions having a single integer input require an explicit cast to type
MWNumericArray
to distinguish the method signature from a standard
interface signature that has no input arguments.
Standard API
Typically, you use the standard interface for MATLAB functions that return multiple output values.
The standard calling interface returns an array of MWArray
rather
than a single array object.
The following table shows the standard API for a generic function with none, one, more than one, or a variable number of arguments.
Generic MATLAB function |
function [Out1, Out2, ..., varargout] = foo(In1, In2, ..., InN, varargin) |
API if there are no input arguments |
public MWArray[] foo(int numArgsOut) |
API if there is one input argument |
public MWArray [] foo(int numArgsOut, MWArray In1) |
API if there are two to N input arguments |
public MWArray[] foo(int numArgsOut, MWArray In1,MWArray In2, \... MWArray InN) |
API if there are optional arguments, represented by the
varargin argument |
public MWArray[] foo(int numArgsOut,MWArray in1,MWArray in2, MWArray InN, params MWArray[] varargin) |
Details about the arguments for these samples of standard signatures are shown in the following table.
Argument | Description | Details |
---|---|---|
numArgsOut | Number of outputs | An integer indicating the number of outputs you want the method to return. The |
In1, In2, ...InN | Required input arguments | All arguments that follow Specify
all required inputs first. Each required input must be of type
|
varargin | Optional inputs | You can also specify optional inputs if your MATLAB code uses the |
Out1, Out2, ...OutN | Output arguments | With the standard calling interface, all output arguments are
returned as an array of |
feval API
In addition to the methods in the single API and the standard API, in most cases, the
MATLAB
Compiler SDK product produces an additional overloaded method. If the original
MATLAB code contains no output arguments, then the compiler will not generate the
feval
method interface.
Consider a function with the following structure:
function [Out1, Out2, ..., varargout] = foo(In1, In2, ..., InN, varargin)
The compiler generates the following API, known as the feval interface.
public void foo (int numArgsOut, ref MWArray [] ArgsOut, MWArray[] ArgsIn)
The interface accepts the following arguments:
numArgsOut | Number of outputs | An integer indicating the number of outputs you want to return. This number generally matches the number of output arguments that
follow. The |
ref MWArray [] ArgsOut | Output arguments | Following A |
MWArray[] ArgsIn | Input arguments |
When you pass an instance of an |