Call MATLAB Function
- Updated2025-03-14
- 3 minute(s) read
Calls the top level MATLAB(R) function from a source file.
The Call MATLAB Function is expandable and shows data types for the wired inputs and outputs. You can configure the Call MATLAB Function to specify the MATLAB session, source path, and function name.
The Call MATLAB Function is not supported on real-time or FPGA targets.

Inputs/Outputs
![]() session in specifies a reference to the MATLAB session. ![]() source file path specifies the absolute path to the source .m file. ![]() error in describes error conditions that occur before this node runs. This input provides standard error in functionality. ![]() return type specifies the data type of return value. You must wire a constant or control matching the data type of the top level MATLAB function return type to return type. For example, if the MATLAB function returns an array of doubles, you must wire an array of doubles constant or control to return type. If the MATLAB function returns multiple values, wire a cluster with elements the correspond to the MATLAB function return values. The name and data types and order of the cluster elements must match the MATLAB function return values. For example, if the MATLAB function returns a numeric, a Boolean array, and a string, you must wire return type to a cluster containing controls or constants of numeric, Boolean array, and string data types in that order. Cluster element names must be unique and not empty. If the MATLAB function does not return any value, leave return type unwired. ![]() input parameter specifies the input parameters of the MATLAB function. You must wire the inputs in the order that the function calls them. You can resize the MATLAB Node to add more terminals. You pass a value to the MATLAB function by wiring to the left terminal of a terminal pair. You read the value of a parameter after the function call by wiring from the right terminal of a terminal pair. ![]() session out returns a reference to the MATLAB session. ![]() error out contains error information. This output provides standard error out functionality. ![]() return value is the return value of the MATLAB function. The data type of return value depends on return type. ![]() |
Supported Data Types
The Call MATLAB Function supports the following data types:
- Numerics
- Arrays, including multi-dimensional arrays. Note 1D arrays are converted to Row Vectors in MATLAB.
- Strings
- Clusters
- Booleans