Define Missing Direction Property
R2026bIn C++, pointer arguments can be used to pass and return data from a function. Use the
Direction property of a clibgen.api.InputArgumentDefinition object when defining arguments in a
MATLAB® interface.
You typically specify this property when programmatically defining or updating argument
behavior in an interface definition. The Direction value determines how
arguments are represented in the generated MATLAB function signature.
The Direction property has one of these values:
"input"— Input argument onlyIf a pointer argument is used to pass data to the function, then it appears as an input argument in the MATLAB signature.
The
Directionvalue for C-string parameters must be input."output"— Output argument onlyIf a pointer argument is used to retrieve data from the function, then it must appear as an output argument in the MATLAB signature.
"inputoutput"— Input and output argumentIf a pointer argument is used to both pass and return data, then it must appear as both an input argument and an output argument.
Note
Default arguments with direction specified as OUT are not supported.
Define these with Direction as "input" or
"inputoutput" in the clibgen.api.InterfaceDefinition
object.
For example, suppose that a C++ function passData has the following
signature. The argument data might be an input to the function, the return
value of the function, or input that the function modifies and returns. The documentation of
the function tells you how the function uses the argument data.
void passData(double *data);
Assuming data is a scalar double value, this table shows the
MATLAB signature based on its role.
C++ Role for data | MATLAB Signature | Set Argument Direction |
|---|---|---|
Input |
passData(data) |
arg = fcn.CPPInputs([fcn.CPPInputs.Name] == "data"); arg.Direction = "input"; |
Return |
[data] = passData() |
arg = fcn.CPPInputs([fcn.CPPInputs.Name] == "data"); arg.Direction = "output"; |
Input and output |
[data] = passData(data) |
arg = fcn.CPPInputs([fcn.CPPInputs.Name] == "data"); arg.Direction = "inputoutput"; |
To return multiple outputs, suppose that function calcXY has this
signature:
void calcXY(double *data, double *X, double *Y);| C++ Role for Parameters | MATLAB Signature | Set Argument Direction |
|---|---|---|
|
[X,Y] = calcXY(data,X,Y) |
arg = fcn.CPPInputs([fcn.CPPInputs.Name] == "data"); arg.Direction = "input"; |
X and Y are input and output
parameters. |
argX = fcn.CPPInputs([fcn.CPPInputs.Name] == "X"); argX.Direction = "inputoutput"; argY = fcn.CPPInputs([fcn.CPPInputs.Name] == "Y"); argY.Direction = "inputoutput"; |
See Also
Objects
clibgen.api.InterfaceDefinition|clibgen.api.InputArgumentDefinition|clibgen.api.OutputArgumentDefinition