Modify the Action Language for a Chart
Stateflow® charts in Simulink® models have an action language property that defines the syntax for state and transition actions. An icon in the lower-left corner of the chart canvas indicates the action language for the chart.
MATLAB® as the action language.
C as the action language.
Convert Charts Between Action Languages
To convert between action languages, change the Action language chart property. In the Chart properties dialog box, select the new action language. If your chart contains actions, Stateflow notifies you of the option to convert syntax patterns.
Change the Default Action Language
MATLAB is the default action language syntax for new Stateflow charts. To create a chart that uses C as the action language, enter:
sfnew -CTo change the default action language of new charts, use the sfpref function. For example, to set C as the action language for
new charts,
enter:
sfpref(ActionLanguage="C");C to MATLAB Syntax Conversion
When you change a chart with existing actions from C action language to MATLAB action language, Stateflow displays a notification at the top of the chart. Click the conversion link in the notification to update supported syntax patterns.
Stateflow converts these C constructs to MATLAB syntax:
Array indexing:
A[0][1]becomesA(1,2)Increment operations:
a++becomesa = a+1Assignment operations:
a += bbecomesa = a+bRemainder operation:
a %% bbecomesrem(a,b)Bit shift operations:
a >> bbecomesbitshift(a,-b)Bitwise operations:
a ^ bbecomesbitxor(a,b)(when Enable C-bit operations is selected)Comments:
//and/* */become%
You must manually update:
Pointer operators such as
&and*.Special assignment operator
:=.Custom data declarations.
Workspace variable access using
mloperator.Functions not supported for code generation.
Hexadecimal notation and single precision literals.
Context-sensitive constants.