This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


This example shows how a WHILE loop and a DO-WHILE can be implemented in Stateflow® in order to create a variable array. The equivalent statements in C-Code are as follows:

WHILE: while(condition < 20) { while_output[i] = condition; i++; condition += 2; }

DO - WHILE: do { do_output[i] = condition; condition += 2; i++; } while(condition < 20);

The variable WHILE_OUTPUT is an array with 10 elements and the variable DO_OUTPUT is 11 elements. Notice that in the scope block, the DO-WHILE loop has an extra value of 20 which is what is expected.

You can use such loops to update or buffer a multi-dimensional variable from within Stateflow.

Was this topic helpful?