Home Examples Using Vectors in Stateflow
AdvancedCoding Tips

Using Vectors in Stateflow

If you wish to use a vector in your Stateflow chart it is essential that if it is a local variable that you set the vector’s size. In addition, if you are using C as the Action Language for Stateflow, then you must also set its starting index. Users familiar with MATLAB will be well aware that MATLAB uses 1-based indexing. In contrast, C is nominally 0-based. If C is used as the Action Language then the starting index can be set within the Model Explorer. Select the vector you wish to work with and look at its properties. On the Value attributestab be sure to set the First index field.

Note: The default Action Language for new Stateflow flow charts is C for MATLAB R2015a and earlier. Starting with R2019b, the default Action Language is MATLAB. See 14.17 Update the Stateflow Action Language to MATLAB for tips on changing the Action Language for existing Stateflow charts.

Figure 10.32: Defining the First Index of a Vector in the Model Explorer

Related Tasks

Coding Tips
Persistent Variables
Persistent variables are ones that hold their value between calls to the embedded MATLAB code they are defined in.
Coding Tips
Custom Control of the Trial Protocol Order
Normally, Dexterit-E manages and controls the order in which Trial Protocols (TPs) execute based on what is defined in the block table of the Task Protocol (see the Dexterit-E User Guide for more details).