Specify Size of Stateflow Data - MATLAB & Simulink (original) (raw)

Main Content

In a Stateflow® chart in a Simulink® model, you specify the size of a data object by:

Use one of these methods to specify the size:

Support for each sizing method depends on the scope of your data.

Scope of Data Method for Sizing Data
Inherit the Size Use Numeric Values Use MATLAB Expressions
Local Only in charts that use MATLAB as the action language Yes Yes
Constant No Yes Yes
Parameter Yes Yes Yes
Input Yes Yes Yes
Output Yes Yes Yes
Data store memory Yes No No

Inherit Data Size

To configure a Stateflow data object to inherit its size from the corresponding Simulink signal or its definition in the chart, specify a size of –1. After you simulate or build your model, you can find the inherited size of the data in the Model Explorer, under the CompiledSize column.

Specify Data Size by Using Numeric Values

When you specify data size by entering a numeric value, follow these guidelines:

In charts that use C as the action language, one-dimensional Stateflow vectors are compatible with Simulink row or column vectors of the same size. For example, a Stateflow input data of size 3 is compatible with a Simulink row vector of size [1 3] or a column vector of size [3 1].

Specify Data Size by Using Expressions

You can specify data size by entering a MATLAB expression that evaluates to one of the size specifications described in Specify Data Size by Using Numeric Values. These guidelines also apply:

Examples of Valid Data Size Expressions

These examples are valid MATLAB expressions for specifying data size in your chart:

Avoid Variables That Can Lead to Naming Conflicts

When a model contains multiple variables with identical names, the variable with the highest priority is used to specify size.

Priority Variable
1 Mask parameter
2 Model workspace variable
3 MATLAB base workspace variable
4 Stateflow data

To avoid confusion, do not specify data size by using a variable name that you define in multiple levels of your model.

Propagate Symbolic Dimensions of Stateflow Data

When you select the model configuration parameter Allow symbolic dimension specification, charts that use C as the action language can propagate the symbolic dimensions of Stateflow data throughout the model. If you have Embedded Coder®, the symbolic dimensions go into the generated code for ERT targets. Specify the size of the symbolic dimensions by using Simulink parameters with one of these storage classes:

For more information, see Allow symbolic dimension specification (Simulink) and Implement Symbolic Dimensions for Array Sizes in Generated Code (Embedded Coder).

Stateflow charts that use MATLAB as the action language do not support symbolic dimension propagation. To specify data size by using Simulink parameters, clear the Allow symbolic dimension specification check box.

See Also

fi (Fixed-Point Designer) | size

Topics