You can define data arguments for MATLAB Function blocks using the following methods:
Method | For Defining | Reference |
---|---|---|
Define data directly in the MATLAB Function block code | Input and output data | See Define Inputs and Outputs. |
Use the Ports and Data Manager | Input, output, and parameter data in the MATLAB Function block that is open and has focus | See Defining Data in the Ports and Data Manager. |
Use the Model Explorer | Input, output, and parameter data in MATLAB Function blocks at all levels of the model hierarchy | See Model Explorer |
To add a data argument, in the Ports and Data Manager, select Add > Data and modify the data properties.
You can set the following properties in the General tab:
Property | Description |
---|---|
Name | Name of the data argument, following the same naming conventions used in MATLAB®. |
Scope | Where data resides in memory, relative to its parent. Scope determines the range of functionality of the data argument. You can set scope to one of the following values:
For more information, see Define Inputs and Outputs and Add Parameter Arguments. |
Port | Index of the port associated with the data argument. This property applies only to input and output data. |
Tunable | Indicates whether the parameter used as the source of this data item is tunable (see Tunable Parameters). This property applies only to parameter data. Clear this option if the parameter must be a constant expression, such as for MATLAB toolbox functions supported for code generation (see Functions and Objects Supported for C/C++ Code Generation). |
Data must resolve to Simulink signal object | Specifies that the data argument must resolve to a Simulink® signal object. This property applies only to output data. This
property appears only if you set the model configuration parameter
Signal resolution to a value other than
None . See Symbol Resolution for more
information. |
Size | Size of the data argument. Size can be a scalar value or a MATLAB vector of values. Size defaults to –1, which means that it is inherited, as described in Inheriting Argument Sizes from Simulink. This property does not apply to Data Store Memory data. For more details, see Size Function Arguments. |
Variable Size | Indicates whether the size of this data item is variable. This property does not apply to Data Store Memory data. |
Complexity | Indicates real or complex data arguments. You can set complexity to one of
the following values:
|
Type |
|
Unit (e.g., m, m/s^2, N*m) | Specify physical units for input and output data. By default, the property is set to inherit the unit from the Simulink signal on the corresponding input or output port. See Units in MATLAB Function Blocks. |
Limit range | Specify the range of acceptable values for input or output data. The MATLAB Function block uses this range to validate the input or output as it enters or leaves the block. You can enter an expression or parameter that evaluates to a numeric scalar value.
|
You can set the following properties on the Description tab:
Property | Description |
---|---|
Save final value to base workspace | The MATLAB Function block assigns the value of the data argument to a variable of the same name in the MATLAB base workspace at the end of simulation. |
Description | Description of the data argument. |
Document link | Link to documentation for the data argument. You can enter a Web URL address or a MATLAB command that displays documentation in a suitable format, such as an HTML file or text in the MATLAB Command Window. When you click the blue text, Document link, displayed at the bottom of the Data properties dialog, the MATLAB Function block evaluates the link and displays the documentation. |