Stateflow | ![]() ![]() |
Typecast Operations
A typecast operator converts a value to a specified data type. Stateflow typecast operators have the same notation as MATLAB typecast operators,
where op
is the typecast operator (e.g, int8
, int16
, int32
, single
, double
) and v
is the value to be converted.
Normally you do not need to use typecast operators in actions. This is because Stateflow checks whether the types involved in a variable assignment differ and, if so, inserts a typecast operator in the generated code. (Stateflow uses the typecast operator of the language in which the target is generated, typically C.) However, if external code defines either or both types, Stateflow cannot determine which typecast, if any, is required. If a type conversion is necessary, you must use a Stateflow action language typecast operator to tell Stateflow which target language typecast operator to generate.
For example, suppose varA
is a data dictionary value of type double
and y is an external variable of type 32 bit integer. The following notation
tells Stateflow to generate a typecast operator that converts the value of varA
to a 32-bit integer before the value is assigned to y
.
![]() | Pointer and Address Operations | Fixed-Point Data | ![]() |