Specify MATLAB Function Block Properties
You can specify how a MATLAB Function block interfaces with a Simulink® model by setting the block properties in the Property Inspector or Model Explorer.
To specify properties in the Property Inspector, open the Property Inspector. In the Modeling tab, in the Design section, select Property Inspector. Click the block to show the properties in the Property Inspector.
To specify properties in the Model Explorer, click the Modeling tab. In the Design section, select Model Explorer. In the Model Hierarchy pane, expand the model tree view, select the MATLAB Function block, and edit the properties in the MATLAB Function pane.
MATLAB Function Block Properties
You can adjust the following properties in the Model Explorer or by navigating to the Properties tab of the Property Inspector.
Specifies the method used for activating the MATLAB Function block.
Input from the Simulink model activates the MATLAB Function block.
If you define an input trigger, the MATLAB Function block executes in response to a Simulink signal or function-call event on the trigger port. If you do not define an input trigger, the MATLAB Function block implicitly inherits triggers from the model. These implicit events are the sample times (discrete or continuous) of the signals that provide inputs to the block.
If you define data inputs, the MATLAB Function block samples at the rate of the fastest data input. If you do not define data inputs, the MATLAB Function block samples at the rate defined by the execution behavior of the parent subsystem.
|Sample the MATLAB Function block using the rate you specify in the Sample time property of the MATLAB Function block. The MATLAB Function block generates an implicit event at regular time intervals that correspond to the specified rate. Note that other blocks in the model can have different sample times.
|Sample the MATLAB Function block at each major time step of the simulation, as well as at intermediate time points requested by the Simulink solver.
Saturate on integer overflow
Specifies how the MATLAB Function block handles overflow conditions during integer operations.
|Action When Overflow Occurs
|Saturates an integer by setting it to the maximum positive or negative value allowed by the word size. This setting matches MATLAB® behavior.
|Generates a run-time error in simulation mode. For Simulink Coder™ code generation, the behavior depends on your C language compiler.
The Saturate on integer overflow option is relevant only for integer arithmetic. It has no effect on fixed-point or double-precision arithmetic.
When you enable Saturate on integer overflow, MATLAB adds additional checks during simulation to detect integer overflow or underflow. Therefore, it is more efficient to disable this option if you are sure that integer overflow and underflow does not occur in your MATLAB Function block code.
Note that the code generated by Simulink Coder does not check for integer overflow or underflow and, therefore, may produce unpredictable results when Saturate on integer overflow is disabled. In this situation, simulate your model to test for overflow and underflow before generating code.
Support variable-size arrays
Specifies if the MATLAB Function block supports input and output data that varies in dimension during simulation. When you enable this property, you can enable variable-size outputs by enabling the Variable size property on output variables. For more information, see Declare Variable-Size MATLAB Function Block Variables and Variable size.
Allow direct feedthrough
Specifies if the MATLAB Function block supports direct feedthrough semantics, so that the output of the block is controlled directly by the value of an input. When you disable Allow direct feedthrough, nondirect feedthrough semantics ensure that outputs rely only on the current state of the block. Using nondirect feedthrough enables you to use MATLAB Function blocks in a feedback loop and prevent algebraic loops. For more information, see Use Nondirect Feedthrough in a MATLAB Function Block.
Interpret output column vectors as one-dimensional data
Specifies if the output of a column vector evaluates as one-dimensional data.
If you enable this property, the block converts output column vectors of size N-by-1 to one-dimensional signals with a signal size equal to N.
If you disable this property, the block outputs column vectors of size N-by-1 as signals with a signal size equal to N-by-1.
Before R2021b, MATLAB Function blocks always converted output column vectors to one-dimensional signals.
Treat dimensions of length 1 as fixed size
Specifies if variables with at least one dimension of length 1 are fixed size. When this property is enabled, the block sets variables that are variable size with a dimension of 1 to fixed size. When this property is disabled, variables in the block that have the Variable size property enabled are always variable size. Prior to R2023a, the block treats variables with at least one dimension of length 1 as fixed size.
This property only affects output variables that have the Variable size property enabled. See Variable size.
You can adjust fixed-point properties for the MATLAB Function block in the Model Explorer or by navigating to the Fixed-point properties section in the Properties tab of the Property Inspector.
Treat these inherited Simulink signal types as fi objects
Specifies whether to treat inherited fixed-point and integer signals as Fixed-Point Designer™
fi (Fixed-Point Designer) objects. For more information, see
Ways to Construct fi Objects (Fixed-Point Designer).
When you select
Fixed-point, the MATLAB Function block treats all fixed-point inputs as Fixed-Point Designer
When you select
Fixed-point & Integer, the MATLAB Function block treats all fixed-point and integer inputs as Fixed-Point Designer
MATLAB Function fimath
fimath properties for the MATLAB Function
fimath on a MATLAB Function block behaves as
globalfimath (Fixed-Point Designer) for the contents of the MATLAB
Function block. The block associates the
fimath properties in
MATLAB Function fimath with all fixed-point and integer input
signals to the MATLAB Function block that you choose to treat as
fi objects. Constructing
fi objects in the
MATLAB Function block introduces additional considerations.
fimathis associated with a
fiobject when it is constructed, then the
ficonstructor uses the default
fimathsettings regardless of the properties in MATLAB Function fimath. However, if you perform additional operations on the
fiobject after it is constructed, the object will adopt the properties in MATLAB Function fimath.
If you specify a
ficonstructor, then that
fimathis obeyed when quantizing the value in the
fimathsettings not specified in the
ficonstructor use the specified properties in MATLAB Function fimath.
You can select one of these options:
|Same as MATLAB
The block uses the same
You can specify your own
Description and Document Link Properties
You can set description and document link properties for the MATLAB Function block in the Model Explorer or by navigating to the Info tab of the Property Inspector.
Specifies the description of the MATLAB Function block. You can enter a brief description and comments.
Specifies the link to the documentation for the data argument. 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.
Programmatically Specify Block Properties
You can specify MATLAB Function block properties programmatically by
Stateflow.EMChart objects of the
block. For more information, see Configure MATLAB Function Blocks Programmatically.