MATLAB Function Block Properties

This section describes each property of a MATLAB Function block.

Name

Name of the MATLAB Function block.

Update method

Method for activating the MATLAB Function block. You can choose from the following update methods:

Update MethodDescription
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.
DiscreteThe 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.
ContinuousThe 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.

Saturate on integer overflow

Option that determines how the MATLAB Function block handles overflow conditions during integer operations:

SettingAction 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.
DisabledIn simulation mode, generates a run-time error. For Simulink Coder™ code generation, the behavior depends on your C language compiler.

Note

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.

Lock Editor

Option for locking the MATLAB Function Block Editor. When enabled, this option prevents users from making changes to the MATLAB Function block.

Treat these inherited Simulink signal types as fi objects

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.

MATLAB Function block fimath

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.

SettingDescription
Same as MATLAB

When you select this option, the block uses the same fimath properties as the current default fimath. The edit box appears dimmed and displays the current global fimath in read-only form.

Specify other

When you select this option, you can specify your own fimath object in the edit box. You can do so in one of two ways:

  • Constructing the fimath object inside the edit box.

  • Constructing the fimath object in the MATLAB or model workspace and then entering its variable name in the edit box. If you use this option and plan to share your model with others, make sure you define the variable in the model workspace. See Sharing Models with Fixed-Point MATLAB Function Blocks (Fixed-Point Designer).

For more information on fimath objects, see fimath Object Construction (Fixed-Point Designer).

Description

Description of the MATLAB Function block.

Document link

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.

Related Examples

More About