Type of Stateflow data object
type( returns the type of a
Stateflow® data object. Use the
type operator to derive the type of
a Stateflow data object from other data objects.
In charts that use C as the action language, you can also use the return value in place
of an explicit type in a
cast operation to convert the value of an
expression to the same type as another data object.
In charts that use MATLAB® as the action language, convert the value of an expression to the same
type as another data object by calling the
cast function with the keyword
"like". For more
information, see Cast Type Based on Other Data.
Derive Data Type from Other Data Objects
Open the example
In the Property Inspector or Model Explorer, use the data type of the input
inbus to define the data type of the local structure
inbus derives its type from the
counterbus_struct also derives its data type from
For more information about this example, see Integrate Custom Structures in Stateflow Charts.
Cast Type Based on Other Data
In a chart that uses C as the action language, cast the expression
x+3 to the same type as data
z and assign its
y = cast(x+3,type(z));
data_name — Data name
name of Stateflow data
Data name, specified as the name of a Stateflow data object.
Introduced before R2006a