MATLAB Function Block Constraints

MATLAB Function Blocks

MATLAB Function Block ConstraintFATAL / NonfatalCompatibility Check

Block names:

  • Must not contain ‘*/’ or ‘/*’.

  • Must not start or end with ‘*’.

NonfatalCheck usage of MATLAB Function Blocks > Check for block names that contain ‘/*’,’*/’, or start or end with the character ‘*’
Output signal storage class must be set to Auto when the block has constant (Inf) sample time.NonfatalCheck usage of MATLAB Function Blocks > Check for unsupported usage of storage class
Output port must not be testpointed when the block has constant (Inf) sample time.NonfatalCheck usage of MATLAB Function Blocks > Check for unsupported testpoints

Output custom signal storage classes:

  • Must have Type set to Unstructured.

  • Must not have Data initialization set to None.

  • Must not reference a signal object with a non-empty initial value.

NonfatalCheck usage of MATLAB Function Blocks > Check storage class of block outports
Input and output ports must be scalars, vectors, or 2–D matrices.NonfatalCheck usage of MATLAB Function Blocks > Check for blocks with greater than two-dimensional inputs or outputs
Input and output ports must not use frame-based signals.NonfatalCheck usage of MATLAB Function Blocks > Check whether inputs and outputs are not framed
MATLAB® function must set Update method to Inherited.NonfatalCheck usage of MATLAB Function Blocks > Check that all MATLAB functions set ‘Update method’ to ‘Inherited’
Function packaging (RTWSystemCode) must be set to Inline. If Nonreusable function or Reusable function is selected, the subsystem and model must be in supported configurations.NonfatalCheck usage of MATLAB Function Blocks > Identify Subsystems that have unsupported configurations for non-inlined
The reusable subsystem in a model must be from a library. It must be unmasked, single-rate atomic or function-call subsystem.NonfatalCheck usage of MATLAB Function Blocks > Check that reusable subsystems in a model are from a library and are unmasked single-rate atomic or function-call subsystems
MATLAB function must not use input Trigger signals.NonfatalCheck usage of MATLAB Function Blocks > Check that MATLAB functions do not contain input Trigger signals
Block that is constant or has parameters that can be tuned must not drive two or more multirate blocks without using explicit Rate Transition blocks.NonfatalCheck usage of MATLAB Function Blocks > Check that blocks that are constant or whose parameters can be tuned, do not drive two or more multirate blocks without using explicit rate transition blocks
Saturate on integer overflow (SaturateOnIntegerOverflow) must not be selected (must be set to off).NonfatalCheck usage of MATLAB Function Blocks > Check that all MATLAB functions set ‘Saturate on integer overflow’ to ‘Off’
Treat these inherited Simulink signal types as fi objects must not be set to Fixed-point & Integer.NonfatalCheck usage of MATLAB Function Blocks > Check that all MATLAB functions set ‘Treat these inherited Simulink signal types as fi objects:’ to a value other than ‘Fixed-point & Integer’
Support variable-size arrays must not be selected (must be set to off).FATALCheck usage of MATLAB Function Blocks > Check that all MATLAB functions set ‘Support variable-size arrays’ to ‘Off’

Data in MATLAB Functions

MATLAB Function Data ConstraintFATAL / NonfatalCompatibility Check
Data defined in a MATLAB function must be of one of the following supported data types: built-in, bus, or an enumerated type inherited from Simulink.IntEnumType.NonfatalCheck usage of Data in MATLAB Functions > Check that data defined in MATLAB function is of a supported data type
Data defined in a MATLAB function must be of one of the following supported dimensions: scalar, vector, or matrix.NonfatalCheck usage of Data in MATLAB Functions > Check that data defined in MATLAB function is of a supported dimension
Data defined in a MATLAB function must be noncomplex.NonfatalCheck usage of Data in MATLAB Functions > Check that data defined in MATLAB function is non-complex

Code in MATLAB Functions

MATLAB Code ConstraintFATAL / NonfatalCompatibility Check

To use non-inlined user-defined functions with global variables in MATLAB code:

  • Functions must not be inside a reusable or void-void subsystem.

  • Model parameter Code interface packaging (CodeInterfacePackaging) must be set to Nonreusable function.

NonfatalCheck usage of Code in MATLAB Functions > Check non-inlined user defined functions with global variables in MATLAB code
Non-inlined user-defined functions in MATLAB code must define only one outputNonfatalCheck usage of Code in MATLAB Functions > Check that non-inlined user defined functions in MATLAB code contain only one output
Array subscripting in MATLAB code must use a constant index value of 1 for a corresponding dimension of size 1.NonfatalCheck usage of Code in MATLAB Functions > Check that array subscripting in MATLAB code uses a constant index of 1 for a corresponding dimension of size 1
Array indexing in MATLAB code must use a subscript that is less than or equal to the array base dimension.NonfatalCheck usage of Code in MATLAB Functions > Check that array indexing in MATLAB code uses a subscript that is less than or equal to the array base dimension

cast function must be of one of the following forms:

  • cast(A,'newclass')

  • cast(A,'like',p)

NonfatalCheck usage of Code in MATLAB Functions > Check type argument for cast in MATLAB functions
colon (:) operator must not have more than 3 operands.NonfatalCheck usage of Code in MATLAB Functions > Check that colon operators in MATLAB code have no more than 3 operands
colon (:) operator must use integer or double data.NonfatalCheck usage of Code in MATLAB Functions > Check that colon operators in MATLAB code use only integer and double data
Data used in a MATLAB function must be of one of the following data types: boolean, int8, int16, int32, uint8, uint16, uint32, single, double, or scalar bus.NonfatalCheck usage of Code in MATLAB Functions > Check that data used in MATLAB function is of a supported data type

A diagonal number specified for the diag function must be a constant. For example, in the statement:

D = diag(v,k)

where k is a diagonal number, k must be a constant.

NonfatalCheck usage of Code in MATLAB Functions > Check that diagonal number used in a diag function in MATLAB code is constant
Identifiers used in assignment, array, function call arguments and function definition arguments must be scalar, vector, or matrix. Identifiers used in any other context must be scalar.NonfatalCheck usage of Code in MATLAB Functions > Check that code in MATLAB function is of a supported dimension
Brackets in MATLAB code must not be empty.NonfatalCheck usage of Code in MATLAB Functions > Check for nonempty brackets in MATLAB code
for statements in MATLAB code must have index ranges that are mono incremental colon expressions.NonfatalCheck usage of Code in MATLAB Functions > Check that for statements in MATLAB code have index ranges that are mono incremental colon expressions
for statements in MATLAB code must have index range values that are literal const integers.NonfatalCheck usage of Code in MATLAB Functions > Check that for statements in MATLAB code have index range values that are literal const integers
for statements in MATLAB code must have scalar index values.NonfatalCheck usage of Code in MATLAB Functions > Check that for statements in MATLAB code have scalar index values
Operands of the dot power operator must be of single or double data type.NonfatalCheck usage of Code in MATLAB Functions > Check that data defined in MATLAB function is of a double or single data type

For MATLAB root functions, if coder.inline directive is specified, it must be set to always.

For user-defined MATLAB functions, the coder.inline directive must be explicitly set to always or never.

NonfatalCheck usage of Code in MATLAB Functions > For MATLAB root function, do not specify coder.inline directive or set coder.inline directive to 'always'. For user defined MATLAB functions, explicitly set coder.inline directive to 'always' or 'never'
Math functions in MATLAB code must use integer or floating-point data.NonfatalCheck usage of Code in MATLAB Functions > Check that math functions in MATLAB code use only integer and floating-point data
MATLAB functions must not have missing data type information.NonfatalCheck usage of Code in MATLAB Functions > Check that no code in MATLAB functions has missing data type information
MATLAB functions must not have missing dimension information.NonfatalCheck usage of Code in MATLAB Functions > Check that no code in MATLAB functions has missing dimension information
Function calls in MATLAB code must resolve to a known function definition.NonfatalCheck usage of Code in MATLAB Functions > Check that all function calls in MATLAB code resolve to a known function definition
Operators in MATLAB functions must not have operands with mixed data type.NonfatalCheck usage of Code in MATLAB Functions > Check that operators used in MATLAB function do not have operands with mixed data type
When using matrix operations in MATLAB code, the Loop unrolling threshold must not result in partially unrolled loops in the generated code.NonfatalCheck usage of Code in MATLAB Functions > Check that the ‘Loop unrolling threshold’ does not result in partially unrolled loops in the generated code when using matrix operations in MATLAB code
Conditional initialization of a persistent variable must use an if statement with a single isempty(persistent) or ~isempty(persistent) condition.NonfatalCheck usage of Code in MATLAB Functions > Check that conditional initialization of persistent variables uses an 'if' statement with a single isempty(persistent) or ~isempty(persistent) condition
Conditional initialization of a persistent variable must contain only one statement in if statement body.NonfatalCheck usage of Code in MATLAB Functions > Check that there is only one initialization statement of a persistent variable in ‘if’ statement body
switch statements must not have case expressions containing a cell array.NonfatalCheck usage of Code in MATLAB Functions > Check that switch statements in MATLAB code do not have case expressions containing a cell array
switch statements must use the same scalar integer type for all switch and case conditions.NonfatalCheck usage of Code in MATLAB Functions > Check that switch statements in MATLAB code use the same scalar integer type for all conditions
The colon (:) function and division operations in MATLAB code must use scalar operands.NonfatalCheck usage of Code in MATLAB Functions > Check that operators and functions in MATLAB code have supported operand dimensions
if statements must use conditions that are scalar.NonfatalCheck usage of Code in MATLAB Functions > Check that if statements in MATLAB code use conditions that are scalar
MATLAB functions must not contain unsupported MATLAB code.NonfatalCheck usage of Code in MATLAB Functions > Check for unsupported MATLAB code in MATLAB functions
Model must not define recursive functions in MATLAB code.NonfatalCheck usage of Code in MATLAB Functions > Check usage of recursive functions in MATLAB code
coder.ceval must not specify the -global option.NonfatalCheck usage of Code in MATLAB Functions > Check that coder.ceval in MATLAB code does not specify '-global' option
coder.ceval must not specify the layout option.NonfatalCheck usage of Code in MATLAB Functions > Check that coder.ceval in MATLAB code does not specify layout option
Subfunctions in MATLAB code must not call function call outputs.NonfatalCheck usage of Code in MATLAB Functions > Check usage of function call outputs in MATLAB code
MATLAB code must not contain the definition of inner function.NonfatalCheck usage of Code in MATLAB Functions > Check usage of inner functions in MATLAB code

MATLAB Code Analyzer Messages

MATLAB Code Analyzer Message ConstraintFATAL / NonfatalCompatibility Check
Issues in MATLAB Function block.NonfatalCheck MATLAB Code Analyzer messages > Check MATLAB code used in MATLAB Function blocks
Issues in called MATLAB functions.NonfatalCheck MATLAB Code Analyzer messages > Check called MATLAB functions

Related Topics