| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
| On this page… |
|---|
Boolean Symbols, true and false Hexadecimal Notation Symbols, 0xFF |
Use the symbols true and false to represent Boolean constants in Stateflow action language. You can use these symbols as scalars in expressions. Examples include:
cooling_fan = true; heating_fan = false;
Do not use true and false in the following cases. Otherwise, error messages appear.
Left-hand side of assignment statements
true++;
false += 3;
[true, false] = my_function(x);
Argument of the change implicit event (see Using Implicit Events)
change(true);
chg(false);
Indexing into a vector or matrix (see How to Assign and Access Values of Vectors and Matrices)
x = true[1];
y = false[1][1];
Note If you define true and false as Stateflow data objects, your custom definitions of true and false override the built-in Boolean constants. |
Use the symbols %, //, and /* to represent comments in Stateflow action language as shown in these examples:
% MATLAB comment line // C++ comment line /* C comment line */
You can also include comments in generated code for an embedded target (see Real-Time Workshop Pane: Comments in the Real-Time Workshop Reference) or a Stateflow custom target (see Configuring a Custom Target). Stateflow action language comments in generated code use multibyte character code. Therefore, you can have code comments with characters for non-English alphabets, such as Japanese Kanji characters.
Stateflow action language supports C style hexadecimal notation, for example, 0xFF. You can use hexadecimal values wherever you can use decimal values.
Use the MATLAB symbol inf to represent infinity in Stateflow action language. Calculations like n/0, where n is any nonzero real value, result in inf.
Note If you define inf as a Stateflow data object, your custom definition of inf overrides the built-in value. |
Use the characters ... at the end of a line of action language to indicate that the expression continues on the next line. For example, you can use the line continuation symbol in a state action:
entry: total1 = 0, total2 = 0, ... total3 = 0;
Use $ characters to mark action language that you want the parser to ignore but you want to appear in the generated code. For example, the parser does not process any text between the $ characters below.
$ ptr -> field = 1.0; $
Omitting the semicolon after an expression displays the results of the expression in the MATLAB Command Window. If you use a semicolon, the results do not appear.
Use a trailing F to specify single-precision floating-point numbers in Stateflow action language. For example, you can use the action statement x = 4.56F; to specify a single-precision constant with the value 4.56. If a trailing F does not appear with a number, double precision applies.
Use the letter t to represent absolute time that the chart inherits from a Simulink signal in simulation targets. For example, the condition [t - On_time > Duration] specifies that the condition is true if the difference between the simulation time t and On_time is greater than the value of Duration.
The letter t has no meaning for nonsimulation targets, since t depends on the specific application and target hardware.
Note If you define t as a Stateflow data object, your custom definition of t overrides the built-in value. |
![]() | Using Operations in Actions | Calling C Functions in Actions | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |