sf_for (Simulink model) Open this Model

FOR Loops

With the use of flow charts, Stateflow allows you to create C-Code or M-Code statements such as the FOR loop. This particular demo shows how you can create a simple FOR Loop that defines an array variable. The equivalent statements in MATLAB are as follows:



for i=1:10
   output = 2 * i;
end

Notice the similarity of the For chart to those in the While loop demo. In each case, a vector output is built up by the loop.