sf_array (Simulink model) | Open this Model |
Vectorization
Stateflow has the ability to vectorize the data inputs and perform 1-D array manipulations. In this example, the following MATLAB code is implemented:
data1=[1 2 3 4]; data2=[2 4 6 8]; output=data1.*data2+1;
Notice the array operator '.' placed before the multiplication sign. Stateflow also implements this vectorization which eliminates the need for DO or FOR loops. The reult is a faster, more efficient code that is also easier to implement.