MATLABFunctionConfiguration - MATLAB Function block property configuration - MATLAB (original) (raw)

MATLAB Function block property configuration

Description

The MATLABFunctionConfiguration object controls the MATLAB Function block properties such as the description, sample time, and function script.

Creation

Each MATLAB Function block has its ownMATLABFunctionConfiguration object. To access this object, use theget_param function. For example, if the model myModel contains a MATLAB Function block called MATLAB Function, enter:

config = get_param("myModel/MATLAB Function", ... "MATLABFunctionConfiguration");

Properties

expand all

This property is read-only.

Path of the MATLAB Function block relative to the model, represented as a character vector.

Data Types: char

Code for the MATLAB Function block, specified as a string scalar or character vector.

Data Types: string | char

Update method for the MATLAB Function block, specified as one of these values:

When you set this property to "Inherited" or"Continuous" and attempt to change SampleTime, Simulink displays a warning and ignores the input sample time.

Data Types: enumerated

Sample time of the MATLAB Function block, specified as a string scalar or character vector. This property applies only when theUpdateMethod property is "Discrete".

Data Types: string | char

Description of the MATLAB Function block, specified as a string scalar or character vector.

Data Types: string | char

Documentation link for the MATLAB Function block, specified as a string scalar or character vector.

Data Types: string | char

Whether the MATLAB Function block supports direct feedthrough semantics, specified as a numeric or logical 1 (true) or0 (false). The block has 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. For more information, see Use Nondirect Feedthrough in a MATLAB Function Block.

Data Types: logical

Since R2021b

Whether the MATLAB Function block outputs column vectors as one-dimensional data, specified as a numeric or logical 0 (false) or 1 (true). When enabled, the block converts vectors of size _N_-by-1 to one-dimensional signals with a signal size equal to N.

Data Types: logical

Since R2023a

Whether the MATLAB Function block treats non-scalar variables with a dimension of length 1 as fixed size, specified as a numeric or logical0 (false) or 1 (true). When this property is true, theMATLAB Function block treats non-scalar variables that have at least one dimension of length 1 as fixed size, regardless of whether you specify the variables as having variable size. When this property is false, theMATLAB Function block treats non-scalar variables as variable size if you specify the variables as having variable size. For more information, see Variable size.

Whether the data in the MATLAB Function block saturates on integer overflow, specified as a numeric or logical 1 (true) or 0 (false). 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 isfalse, the 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 enable this setting. If you have performance restrictions or are not concerned with integer overflow, you can disable this setting.

Data Types: logical

Inherited Simulink signals to treat as Fixed-Point Designer™fi objects, specified as one of these values:

To learn more about fi objects, see Set fi Object Properties (Fixed-Point Designer).

Data Types: enumerated

Default fimath properties for the MATLAB Function block, specified as one of these values:

To learn more about fixed-point math, see fimath (Fixed-Point Designer).

Data Types: enumerated

Default fimath object, specified as a string scalar or character vector. When the FimathMode property for the MATLAB Function block is "UserSpecified", you can use this property to:

To learn more about fimath object properties, see fimath Object Properties (Fixed-Point Designer).

Data Types: string | char

Object Functions

Examples

collapse all

Access the MATLABFunctionConfiguration object for the MATLAB Function block in the model call_stats_block1 described inImplement MATLAB Functions in Simulink with MATLAB Function Blocks.

config = get_param("call_stats_block1/MATLAB Function", ... "MATLABFunctionConfiguration");

Set the value of the Description property.

config.Description = "Calculate the mean and standard deviation for a vector of values.";

Access the MATLABFunctionConfiguration object for theMATLAB Function block in the modelcall_stats_block2 described in Implement MATLAB Functions in Simulink with MATLAB Function Blocks.

config = get_param("call_stats_block2/MATLAB Function", ... "MATLABFunctionConfiguration");

Create the MATLABFunctionReport object for the MATLAB Function block.

report = getReport(config);

Access the coder.Function objects in the report.

functions = report.Functions;

Create a custom report that lists the functions and variables in the MATLAB Function block.

for i = 1:numel(functions) fprintf("Function %s uses these variables:\n",functions(i).Name) variables = functions(i).Variables; for j = 1:numel(variables) fprintf("%d. %s -- %s\n",j,variables(j).Name,variables(j).Scope) end fprintf("\n") end

Function stats uses these variables:

  1. mean -- Output
  2. stdev -- Output
  3. vals -- Input
  4. len -- Local

Function avg uses these variables:

  1. mean -- Output
  2. array -- Input
  3. size -- Input

Version History

Introduced in R2019b

expand all

With the new property [TreatDimensionOfLengthOneAsFixedSize](simulink.matlabfunctionconfiguration.html#mw%5Fd1149f74-789d-4983-af86-cdf071b13d6c), you can specify how MATLAB Function blocks treat output variables when at least one dimension has length 1. Prior to R2023a, MATLAB Function blocks treat output variables with a dimension of length 1 as fixed size, regardless of whether you specify the variables as having variable size.

You can output column vectors in MATLAB Function blocks as two-dimensional or one-dimensional data with the VectorOutputs1D property.

Before R2021b, MATLAB Function blocks always output column vectors as one-dimensional data. After R2021b, MATLAB Function blocks output column vectors as two-dimensional data by default. To maintain the original behavior of the block, set the VectorOutputs1D property to true.

You can access MATLAB function reports for MATLAB Function blocks by calling these functions on MATLABFunctionConfiguration objects: