This section describes each property of a MATLAB Function block.
Method for activating the MATLAB Function block. You can choose from the following update methods:
Update Method | Description |
---|---|
Inherited (default) | 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 chart. 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 as defined by its parent subsystem's execution behavior. |
Discrete | The MATLAB Function block is sampled at the rate you specify as the block's Sample Time property. An implicit event is generated at regular time intervals corresponding to the specified rate. The sample time is in the same units as the Simulink simulation time. Note that other blocks in the model can have different sample times. |
Continuous | The Simulink software wakes up (samples) the MATLAB Function block at each step in the simulation, as well as at intermediate time points that can be requested by the solver. This method is consistent with the continuous method. |
Option that determines how the MATLAB Function block handles overflow conditions during integer operations:
Setting | Action When Overflow Occurs |
---|---|
Enabled (default) | Saturates an integer by setting it to the maximum positive or negative value allowed by the word size. Matches MATLAB® behavior. |
Disabled | In simulation mode, generates a run-time error. 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 will 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, it is recommended that you simulate first to test for overflow and underflow before generating code.
Option for locking the MATLAB Function Block Editor. When enabled, this option prevents users from making changes to the MATLAB Function block.
Setting that determines whether to treat inherited fixed-point and integer signals as
Fixed-Point
Designer™
fi
objects (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
fi
objects.
When you select Fixed-point & Integer
, the
MATLAB Function block treats all fixed-point and integer inputs as
Fixed-Point
Designer
fi
objects.
Setting that defines fimath
properties for the MATLAB
Function block. The block associates the fimath
properties you
specify with the following objects:
All fixed-point and integer input signals to the MATLAB Function
block that you choose to treat as fi
objects.
All fi
and fimath
objects constructed in the
MATLAB Function block.
You can select one of the following options for the MATLAB Function block fimath.
Setting | Description |
---|---|
Same as MATLAB | When you select this option, the block uses the same
|
Specify other | When you select this option, you can specify your own
For more information on |
Link to documentation for the MATLAB Function block. To document a MATLAB Function block, set the Document link property to a Web URL address or MATLAB expression that displays documentation in a suitable format (for example, an HTML file or text in the MATLAB Command Window). The MATLAB Function block evaluates the expression when you click the blue Document link text.