Set Properties for MATLAB Function Block Variables
You can set properties that modify how the variables in your MATLAB Function blocks interface with the Simulink® model. For more information on creating variables in MATLAB Function blocks, see Create MATLAB Function Block Variables.
You can modify the properties of a variable by using the Symbols pane and the Property Inspector or by using the Model Explorer.
To edit the properties by using the Symbols pane and Property Inspector:
Double-click the MATLAB Function block to open the MATLAB Function Block Editor.
In the Function tab, click Edit Data.

In the Symbols pane, select the variable. The properties display in the Property Inspector. If the Property Inspector is closed, click Edit Data to open it.
To edit the properties by using the Model Explorer:
In the Modeling tab, in the Design section, click Model Explorer.
In the Model Hierarchy pane, expand the model tree view and select the MATLAB Function block.
Click a variable, then edit the properties in the right pane.
Set General Variable Properties
You can modify these properties in the Properties tab in the Property Inspector or the General tab of the model explorer.
Name
Specifies the name of the variable. Use the same naming conventions used in MATLAB®. You can also modify this property in the Symbols pane directly.
Changing the name in the Symbols pane only adjusts variables in the function declaration statement, and does not change the name of the variable used throughout the body of the code. If you want to adjust the variable throughout the code, enter the Name property in the Symbols pane and press Shift + Enter.
Scope
Specifies where the variable resides in memory relative to its parent. This property determines the functionality of the variable. You can also modify this property in the Type column of the Symbols pane. You can set Scope to one of these values:
| Scope | Description |
|---|---|
Parameter | The variable retrieves data from a variable of the same name in the
MATLAB workspace, the model workspace, or in the workspace of a masked
subsystem that contains this block. If a variable of the same name exists in more
than one of the workspaces visible to the block, the block uses the variable
closest to the block in the workspace hierarchy. The Symbols
pane indicates the variable has Scope set to
Parameter with the Parameter Data icon
|
Input | The variable is an input signal to the MATLAB Function block.
The Symbols pane indicates the variable has
Scope set to Input with the
Input Data icon |
Output | The variable is an output signal of the MATLAB Function block.
The Symbols pane indicates the variable has
Scope set to Output with the
Output Data icon |
Data Store Memory | The variable resides in a Data Store Memory block in the
model, or in a Simulink.Signal in the model or base workspace.
The Symbols pane indicates the variable has
Scope set to Data Store Memory
with the Data Store Memory icon |
Port
This property applies only to variables with the Scope property
set to Input or Output.
Specifies the index of the port associated with the variable.
Data must resolve to signal object
This property appears only if you set the configuration parameter Signal
resolution to a value other than None and to
variables with the Scope property set to
Output.
Specifies that the variable resolves to a Simulink signal object. For more information, see Symbol Resolution.
Size
This property does not apply to variables with the Scope property
set to Data Store Memory.
Specifies the size of the variable. This property can be a scalar value or a
MATLAB vector of values. Size defaults to
–1, which means that the size is inherited. For more information, see
Specify Size of MATLAB Function Block Variables.
Variable size
This property appears only if the MATLAB Function block property Support variable-size arrays is enabled. See Support variable-size arrays.
Specifies whether the size of the variable can change or is fixed. This property
applies only to variables with the Scope property set to
Output. For more information, see Declare Variable-Size MATLAB Function Block Variables.
Input variables inherit size variability from their corresponding signals. Variables in both the input and output of the function declaration statement also automatically inherit size variability.
Tunable
This property applies only to variables with the Scope property
set to Parameter.
Specifies whether the parameter used as the source of this variable data is tunable. For more information, see Tunable Parameters. Clear this option if the parameter must be a constant expression, such as for toolbox functions supported for code generation. For more information, see Functions and Objects Supported for C/C++ Code Generation.
Complexity
This property does not apply to variables with the Scope
property set to Data Store Memory.
Specifies real or complex variables. Set Complexity to one of the following values:
| Complexity | Description |
|---|---|
Inherited | Variable inherits complexity based on the Scope property. Input and output variables inherit complexity from the Simulink signals connected to the associated input or output ports. Parameter variables inherit complexity from the specified parameter. |
Off | Variable is a real number. |
On | Variable is a complex number. |
Type
This property does not apply to variables with the Scope property
set to Data Store Memory.
Specifies the data type for the variable. You can specify the data type by:
Selecting a built-in type from the Type property.
Entering an expression in the Type property that evaluates to a data type. See About Data Types in Simulink.
Using the Data Type Assistant to specify the Mode property, then specifying the data type based on that mode.
Note
To display the Data Type Assistant, click the Show data type assistant button
.
For more information, see Specify Data Types of Variables in MATLAB Function Blocks.
Unit (e.g., m, m/s^2, N*m)
This property applies only to variables with the Scope property
set to Input or Output.
Specifies the physical units for the variable. By default, this property is set to inherit the unit from the Simulink signal on the corresponding input or output port. See Specify Units in MATLAB Function Blocks.
Set Limit Range Properties
These properties apply only to variables with the Scope property
set to Input or Output.
You can set the range of acceptable values for variables in the Limit range section of the Property Inspector or Model Explorer. The MATLAB Function block uses this range to validate the data as it enters or leaves the block. You can enter an expression or parameter that evaluates to a numeric scalar. Specify the range by using two properties.
Minimum
The smallest value allowed for the variable during simulation. The default value is
-inf.
Maximum
The largest value allowed for the variable during simulation. The default value is
inf.
Set Description Properties
You can modify the description properties of a variable by using the Property Inspector or the Model Explorer. In the Property Inspector, edit the properties in the Info tab. In the Model Explorer, click a variable, then edit the properties in the Description tab.
Save final value to base workspace
This property applies only to variables with the Scope property
set to Input or Output. This
property appears only in the Model Explorer.
Specifies if the MATLAB Function block assigns the value of the variable to a variable of the same name in the MATLAB base workspace after simulation.
Description
Specifies the description of the variable.
Document link
Specifies the link to the documentation for the variable. You can enter a URL address or a MATLAB command that displays documentation, such as an HTML file or text in the MATLAB Command Window. When you click the Document link link, the MATLAB Function block evaluates the link and displays the documentation.