Symbolic Dimensions Supported Block Constraints and Limitations
For a list of supported blocks, see the Block Support Table. To find out which blocks
support symbolic dimension specification, enter showblockdatatypetable
at
the MATLAB® command prompt. Unsupported blocks (for example, MATLAB Function
block) can still work in a model containing symbolic dimensions as long as they do not
directly interact with symbolic dimensions.
Cases Where Supported Blocks Do Not Propagate Symbolic Dimensions
In the following cases, supported blocks do not propagate symbolic dimensions.
For Assignment and Selector blocks, you set the Block Parameters > Index Option parameter to
Index vector (dialog)
. If you specify a symbolic dimension for the Index parameter for these blocks, the code generator does not honor the symbolic dimension in the generated code.For the Product block, you specify a value of
1
for the Block Parameters > Number of inputs parameter, and you set the Multiply over parameter toSpecified dimensions
.For the For Each block, you specify a symbolic dimension for the Partition Width parameter.
Modeling Patterns That Can Cause Simulink Errors
Note that the following modeling patterns are among those modeling patterns that can cause Simulink to error out:
For Switch blocks, if an input signal or the Threshold parameter has symbolic dimensions, and you select Allow different data input sizes (Results in variable-size output signal).
A Data Store Read block selects elements of a
Simulink.Bus
signal that has symbolic dimensions.For Lookup Table blocks, on the Block Parameters > Algorithm tab, you select the parameter Use one input port for all input data.
Code Generation Optimization Considerations
When you create a model with symbolic dimensions, consider the following optimization aspects:
The code generator reuses buffers only if dimension propagation establishes equivalence among buffers.
Two loops with symbolic loop bound calculations are fused together only if they share equivalent symbolic expression.
Optimizations do not eliminate a symbolic expression or condition check based on the current value of a symbolic dimension.
Backward Compatibility
If an existing model uses Simulink.Parameter
objects to specify
dimensions, it may be incompatible with symbolic dimensions. Two common scenarios
are:
Only a subset of blocks accepts symbolic dimension specifications. If a block is not compatible with symbolic dimensions, it causes an update diagram error.
Simulink.Parameter
objects that you use to define symbolic dimensions or have symbolic dimensions must have one of the storage classes prescribed. If these specifications are not met, the build procedure for the model fails during code generation.
To address the backward compatibility issues:
Turn off the symbolic dimensions feature by clearing the Allow symbolic dimension specification parameter in the Configuration Parameters dialog box.
Update
Simulink.Parameter
objects that define symbolic dimensions or have symbolic dimension specifications.Update the model so that only supported blocks have symbolic dimensions or propagate symbolic dimensions.
Symbolic Dimensions Limitations
The following products and software capabilities support symbolic dimensions by acting on their numeric values. However, they do not support the propagation of symbolic dimensions during model simulation and the preservation of symbolic dimensions in the generated code.
Code Replacement for Lookup Tables
Software-in-the-Loop (SIL) and Processor-in-the-Loop (PIL) simulations
Accelerator and rapid accelerator simulation modes
Scope and simulation observation (for example, logging, SDI, and so on)
Model coverage
Simulink Design Verifier
Fixed-Point Designer
Data Dictionary
Simulink PLC Coder
HDL Coder
The following do not support symbolic dimensions:
System Object
Stateflow charts that use MATLAB as the action language
Physical modeling
Discrete-event simulation
Frame data
MATLAB functions
Additional Limitations for Models Using Symbolic Dimensions
The following limitations also apply to models that utilize symbolic dimensions.
For simulation, the size of a symbolic dimension can be 1. For code generation, the size of a symbolic dimension must be greater than
1
.The symbolic dimension is expressed in the code as a macro (
#define
) corresponding to a literal number. The compiler interprets this number as integer data type, and because of this, the data type for the symbolic dimension should match the target integer type to ensure compatibility.Code generation is not supported if Variable-size signals configuration parameter is enabled for models with symbolic dimensions.
If a symbolic dimension is a MATLAB expression that includes an arithmetic expression combined with a relational or logical expressions, add
+0
after the relational or logical part of the MATLAB expression to avoid simulation errors. Adding+0
converts the data type of the relational or logical part of the expression from aboolean
to adouble
.For example, if you have an expression
[(C==8)*D+E,3]
with the Data type parameter set todouble
. SinceC==8
is a relational expression, you must modify the expression to[((C==8)+0)*D+E,3]
to avoid simulation errors.Simulink propagates symbolic dimensions for an entire structure or matrix but not for a part of a structure or matrix. For example, consider the
Simulink.Parameter
P
is a2x3
matrix with symbolic dimensions[Dim,Dim1]
.p=Simulink.Parameter(struct('A',[1 2 3;4 5 6])) p.DataType='Bus:bo' bo=Simulink.Bus bo.Elements(1).Name='A' bo.Elements(1).Dimensions='[Dim,Dim1]' Dim=Simulink.Parameter(2) Dim1=Simulink.Parameter(3) p.CoderInfo.StorageClass='Custom' p.CoderInfo.CustomStorageClass='Define' Dim.CoderInfo.StorageClass='Custom' Dim.CoderInfo.CustomStorageClass='Define' Dim1.CoderInfo.StorageClass='Custom' Dim1.CoderInfo.CustomStorageClass='Define'
If you specify
p.A
for a dimensions parameter, Simulink propagates the symbolic dimensions[Dim,Dim1]
. If you specifyp.A(1,:)
, Simulink propagates the numeric dimension3
but not the symbolic dimension,Dim1
.MATLAB expressions that do not maintain symbolic dimension information:
A(:)
. UseA
instead.P(2:A)
. Use the Selector block instead.P(2,:)
, not a tunable expression.
Suppose that you set the value of a mask parameter,
myMaskParam
, by using a field of a structure or by using a subset of the structures in an array of structures. You store the structure or array of structures in aSimulink.Parameter
object so that you can use aSimulink.Bus
object to apply symbolic dimensions to the structure fields. Under the mask, you configure a block parameter to use one of the fields that have symbolic dimensions. The table shows some example cases.Description Value of mask parameter ( myMaskParam
)Value of block parameter myStruct
is a structure with fieldgains
, which uses symbolic dimensions.myStruct.gains
myMaskParam
myStruct
is a structure with field hierarchymyStruct.subStruct.gains
. The fieldgains
uses symbolic dimensions.myStruct.subStruct
myMaskParam.gains
myStructs
is an array of structures. Each structure has a fieldgains
, which uses symbolic dimensions.myStructs(2)
myMaskParam.gains
In these cases, you cannot generate code from the model. As a workaround, choose one of these techniques:
Use the entire structure (
myStruct
) or array of structures (myStructs
) as the value of the mask parameter. Under the mask, configure the block parameter to dereference the target field from the mask parameter by using an expression such asmyMaskParam.subStruct.gains
.Use literal dimensions instead of symbolic dimensions for the target field (
gains
).
This limitation also applies when you use a field of a structure or a subset of the structures in an array of structures as the value of a model argument in a Model block.