| Stateflow® | ![]() |
| On this page… |
|---|
A Stateflow® action uses C style syntax and zero-based indexing by default to access array elements. This differs from MATLAB® notation, which uses 1-based indexing. For example, suppose you define a Stateflow input A of size [3 4]. To access the element in the first row, second column, use the expression A[0][1]. Here are other examples of how to access and assign values to array elements in Stateflow actions:
local_array[1][8][0] = 10; local_array[i][j][k] = 77; var = local_array[i][j][k];
As an exception to this style, scalar expansion is available within the action language. This statement assigns a value of 10 to all the elements of the array local_array.
local_array = 10;
Scalar expansion is available for performing general operations. This statement is valid if the arrays array_1, array_2, and array_3 have the same value for the Sizes property.
array_1 = (3*array_2) + array_3;
Note Use the same notation for accessing arrays in Stateflow charts, from Simulink® models, and from custom code. |
Stateflow action language provides the same syntax for Stateflow arrays and custom code arrays.
Note Any array variable that is referred to in a Stateflow chart but is not defined in the Stateflow hierarchy is identified as a custom code variable. |
![]() | Using Data and Event Arguments in Actions | Broadcasting Events in Actions | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |