This example shows the use of Change detection feature that allows a condition in a Stateflow® chart to query whether a chart input or local variable has changed value since the last time step. This example shows how this feature could be applied to vectors and matrices.
A vector is sent as input to the Stateflow chart named 'Vector Change Detection'. The first element of this vector is the output of a Repeating Sequence Generator. In other words, the first element of this vector is constantly changing. If you double click the 'Vector Change Detection' chart you will notice that the output y should get incremented every time the input vector u changes. Notice that hasChanged has been applied to the entire vector u where a change in any element of the vector u results in this operator returning a value of 1. Run the simulation and observe the value of y on the scope.