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

Share this Task

Related Tasks

Psychology Tasks
Stroop
This task quantifies cognitive inhibition and information processing speed.
Psychology Tasks
Simon
This task quantifies the influence of congruence between the spatial position of a stimulus and the required response.