Configure MATLAB Function block properties programmatically
MATLABFunctionConfiguration object controls the
MATLAB Function block properties such as description, sample time, and the
function script. You can create a configuration object using
change the property values of the object using dot notation.
myMFBConfigobj = get_param(gcb, 'MATLABFunctionConfiguration')
creates a MATLAB Function block configuration object for the selected
MATLAB Function block.
Path— Path of the block relative to the model
Display the path of the MATLAB Function block relative to the model.
FunctionScript— Block function script
Display the script for the MATLAB Function block.
UpdateMethod— Block update method
Update method of the block, specified as an enumerated string.
UpdateMethod using one of these values:
Inherited — Input to the MATLAB Function block
determines when the block is updated during a simulation. The input is explicitly
triggered by a signal on its trigger port originated from a connected Simulink® block. If the
UpdateMethod is changed to the
'Inherited', the sample time automatically sets to
Discrete — Simulink model generates an implicit event at regular time intervals to awaken
the block at the rate you specify in the
Other blocks in the model can have different sample times.
Continuous — The MATLAB Function block
updates at major time steps only, although it computes outputs and local continuous
variables during minor and major time steps. If the
is changed to
'Continuous', the sample time automatically sets to
When you set the
Continuous and attempt to change
Simulink displays a warning and ignores the input sample time.
Open the Ports and Data Manager and change the Update Method to the method you choose.
SampleTime— Block sample time
Change the sample time of the MATLAB Function block. Sample time is
only valid when the
UpdateMethod is set to
Discrete. If the
UpdateMethod is set to
'Inherited', any changes made to
the sample time are ignored.
Open the Ports and Data Manager and change the Sample Time.
Description— Block Description
Description of the block, specified as a character vector.
Open the Ports and Data Manager and change the Description to the text you choose.
DocumentLink— Documentation link for the block
Documentation link for the block, specified as a character vector.
Open the Ports and Data Manager and change the Document Link to your block documentation link.
SupportVariableSizing— Support variable input and output data
Specify whether the simulation supports variable input and output data dimensions.
Open the Ports and Data Manager and check the Support variable-size arrays to turn this setting on.
AllowDirectFeedthrough— Direct feedthrough status of the block
Display or change whether the block has direct feedthrough. The block is considered to have direct feedthrough if the output of the block directly depends on the input of the block. The block does not have direct feedthrough if the outputs of the block depend on the internal states and properties rather than the input of the block.
Open the Ports and Data Manager and check the Allow direct feedthrough to turn this setting on.
SaturateonIntegerOverflow— Specify whether overflows saturate
Specify whether the integer overflow saturates. If this setting is set to
true, the overflows saturate to either the minimum or maximum value
that the data type can represent. If the setting is
overflow wraps to the appropriate value that the data type can represent. If your model
has a possible overflow, and you want to apply saturation protection in your generated
code, it is recommended to have this setting on. If you have performance restrictions,
and not concerned with the integer overflow, you can set this property to
Open the Ports and Data Manager and check the Saturate on integer overflow box to turn this setting on.
TreatAsFi— Specify data types as
Specify which data types to treat as
fi data types. To learn more
fi objects, see fi Object Properties (Fixed-Point Designer).
Open the Ports and Data Manager and select an option from the Treat these inherit Simulink signal types as fi objects menu.
FimathMode— Specify fixed-point settings
Specify which fixed-point math settings to use. You can use the current MATLAB® fixed-point math settings, or you can enable the edit box to specify the
desired fixed-point math settings. To learn more about fixed-point math, see
Open the Ports and Data Manager and choose from the MATLAB Function fimath settings.
Fimath— Specify the fixed-point math settings
fimath construction function you want to use.
fimath(...'PropertyName',PropertyValue...) allows you to set the
attributes of a
fimath object using property name/property value
pairs. To learn more
fimath object properties, see fimath Object Properties (Fixed-Point Designer).
Open the Ports and Data Manager and edit the MATLAB
Function fimath box with the appropriate
This example creates a MATLAB Function block configuration object using
open_system('sldemo_radar_eml') myMFBConfig = get_param('sldemo_radar_eml/MATLAB Function','MATLABFunctionConfiguration'); myMFBConfig.Description = 'Radar data processing tracker using Extended Kalman';