| Contents | Index |
| On this page… |
|---|
Define a vector in a Stateflow chart as follows:
Add data to your chart as described in Adding Data.
In the General pane of the Data properties dialog box, enter the dimensions of the vector in the Size field.
For example, enter [4 1] to specify a 4-by-1 vector.
Specify the name, base type, and other properties for the new data.
Note Vectors cannot have the base type ml. See Rules for Using Vectors and Matrices in Stateflow Charts. |
Set initial values for the vector.
If initial values of all elements are the same, enter a real number in the Initial value field. This value applies to all elements of a vector of any size.
If initial values differ, enter real numbers in the Initial value field. For example, you can enter:
[1; 3; 5; 7]
Click Apply.
Define a matrix in a Stateflow chart as follows:
Add data to your chart as described in Adding Data.
In the General pane of the Data properties dialog box, enter the dimensions of the matrix in the Size field.
For example, enter [3 3] to specify a 3-by-3 matrix.
Specify the name, base type, and other properties for the new data.
Note Matrices cannot have the base type ml. See Rules for Using Vectors and Matrices in Stateflow Charts. |
Set initial values for the matrix.
If initial values of all elements are the same, enter a real number in the Initial value field. This value applies to all elements of a matrix of any size.
If initial values differ, enter real numbers in the Initial value field. For example, you can enter:
[1 2 3; 4 5 6; 7 8 9]
Click Apply.
![]() | How Vectors and Matrices Work in Stateflow Charts | Scalar Expansion for Converting Scalars to Nonscalars | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |