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, Ports and Data Manager, or Model Explorer.
To specify properties in the Property Inspector, click the Modeling tab. In the Design section, select Property Inspector. Click the MATLAB Function block to see the MATLAB Function block properties.
To specify properties in the Ports and Data Manager, double click the MATLAB Function block to open the MATLAB Function Block Editor. Click Ports & Data Manager. To access the MATLAB Function block properties, click the Show Block Dialog button .
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 Ports and Data Manager and 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.
|Setting||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.|
|Disabled||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. For more information, see Declare Variable-Size Inputs and Outputs.
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.
You can adjust fixed-point properties for the MATLAB Function block in the Ports and Data Manager and 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
For more information on
Description and Document Link Properties
You can set description and document link properties for the MATLAB Function block in the Ports and Data Manager or 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.