Variable-size data is data whose size can change at run time. In contrast, fixed-size data is data whose size is known and locked at compile time and does not change at run time. Use variable-size data if the output from a Stateflow® chart in a Simulink® model is an array whose size depends on the state of the chart.
Stateflow charts exchange variable-size data with other charts and blocks in their models through MATLAB® functions, Simulink functions, and truth tables that use MATLAB as the action language. You pass variable-size data to these functions as chart-level inputs and outputs from state actions and transition logic. However, you must perform all computations with variable-size data inside the functions, not directly in states or transitions. For more information about the functions that interact with variable-size, chart-level inputs and outputs, see:
Support for variable-size data is enabled by default. To modify this option for individual charts:
Right-click an open area of the chart and select Properties.
In the Chart properties dialog box, select or clear the Support variable-size arrays check box.
After enabling support at the chart level, you can declare variable-size inputs and outputs.
Add a data object to the chart, as described in Add Stateflow Data.
Set Scope property as
Select the Variable size check box.
Set the Size property for the data.
|Scope||What to Specify|
|Specify the explicit size and upper bound.|
For example, this specification declares a variable-size input
data that inherits its Size and
Type from the Simulink model. To specify a 2-D matrix where the upper bounds are 2 for the first
dimension and 4 for the second dimension, in the Size field, enter
[2 4] instead.
Declare variable-size data as chart inputs and outputs only, not as local data.
Do not perform computations with variable-size data directly in states or transitions.
Perform all computations with variable-size data in MATLAB functions, Simulink functions, and truth tables that use MATLAB as the action language.
You can pass the data as inputs and outputs to MATLAB and Simulink functions in your chart from state actions and transition logic. MATLAB functions can also access the chart-level, variable-size data directly. For more information, see Compute Output Based on Size of Input Signal.