Sizing Stateflow Data

About Stateflow Data Sizes

Stateflow data can be a scalar, vector, or N-dimensional matrix, depending on its scope (see Size).

How to Specify Data Size

You specify the size of Stateflow data as a scalar value or a MATLAB vector of values in the Size field of the Data properties dialog box, as described in Properties You Can Set in the General Pane.

You can enter size as a constant value or an expression. Stateflow input and output data objects can also inherit their sizes from the Simulink signals that connect to them.

Sizing Data as a Constant Value

In the Data properties dialog box, you specify scalar data by setting the Size field to 1 or leaving it blank.

You specify MATLAB vectors and matrices as multidimensional arrays, where the number of dimensions equals the length of the vector, and the size of each dimension corresponds to the value of each element of the vector. Enter the size of two-dimensional arrays in [row column] format.

One-dimensional Stateflow data arrays are compatible with Simulink row or column vectors of the same size. For example, Stateflow input or output data of size 3 is compatible with a Simulink row vector of size [1,3], or column vector of size [3,1]. To define a row vector of size 5, set the Size field to [1 5]. To define a column vector of size 6, set the Size field to [6 1] or just 6.

Sizing Data by Expression

You can use a mathematical expression to set the size of Stateflow data. Size expressions must evaluate to a positive integer.

In the Size field of the Data properties dialog box, you can enter a MATLAB expression for each dimension. Expressions can contain a mix of numeric constants, Stateflow constants, arithmetic operators, parameters, and calls to functions such as size, min, and max. Valid size expressions include:

k+1
size(x)
min(size(y),k)

For more information about expressions, see Entering Expressions and Parameters for Data Properties.

Inheriting Input and Output Data Size from Simulink Signals

To configure Stateflow input and output data objects to inherit size from the corresponding Simulink input and output signals, enter -1 in the Size field of the Data properties dialog box. This default setting applies to input and output data that you add in the Stateflow Editor (see Adding Data). After you build your model, the Compiled Size column of the Model Explorer displays the actual size that the compiled simulation application uses.

In the following example, the input data invals connects to a Constant block that specifies a four-element vector. The Compiled Size column displays the correct inherited size of 4 for invals.

Inheriting the size of input data is complete for all cases. Chart actions that store values in the specified output infer the inherited size of output data. If the expected size in the Simulink model matches the inferred size, inheritance is successful. Otherwise, a mismatch occurs during build time.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS