This section describes each property of a 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 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.|
|Setting||Action When Overflow Occurs|
|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.
When you select
Fixed-point, the MATLAB
Function block treats all fixed-point inputs as Fixed-Point
When you select
Fixed-point & Integer, the
MATLAB Function block treats all fixed-point and integer inputs as
All fixed-point and integer input signals to the MATLAB Function
block that you choose to treat as
fimath objects constructed in the
MATLAB Function block.
You can select one of the following options for the MATLAB Function block fimath.
|Same as MATLAB|
When you select this option, the block uses the same
When you select this option, you can specify your own
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.