Stateflow User's Guide Previous page   Next Page

Using Special Symbols in Actions

Stateflow notation uses the symbols inf, NaN, t, $, ..., %, //, /*, ;, F, and hexadecimal notation to provide the user with special features in action language notation as described in the following topics:

Comment Symbols

Use the the symbols %, //, and /* to represent comments in Stateflow action language as shown in the following examples:

You can optionally include comments in Stateflow generated code for a Real-Time Workshop target (see "Real-Time Workshop Options" in the Real-Time Workshop documentation) or a Stateflow custom target (see Configuring a Custom Target in Stateflow). Stateflow action language comments in generated code are represented with multibyte character code. This means that you can have comments in code with characters for non-English alphabets such as Japanese Kanji characters.

Hexadecimal Notation Symbols

Stateflow action language supports C style hexadecimal notation. For example, 0xFF. You can use hexadecimal values wherever you can use decimal values.

Infinity Symbol, inf

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.

Line Continuation Symbol, ...

Use the characters ... at the end of a line of action language to indicate that the expression continues on the next line.

Literal Code Symbol, $

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 is completely disabled during the processing of anything between the $ characters. Frequent use of literals is discouraged.

MATLAB Display Symbol, ;

Omitting the semicolon after an expression displays the results of the expression in the MATLAB Command Window. If you use a semicolon, the results are not displayed.

Single-Precision Floating-Point Number Symbol, F

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, it is assumed to be double-precision.

Time Symbol, t

Use the letter t to represent absolute time inherited from Simulink in simulation targets. For example, the condition [t - On_time > Duration] specifies that the condition is true if the value of On_time subtracted from the simulation time t is greater than the value of Duration.


Previous page  Type Cast Operations Calling C Functions in Actions Next page

© 1994-2005 The MathWorks, Inc.