Main Content

type

Type of Stateflow data object

Description

example

type(data_name) 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.

Tip

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.

Examples

expand all

Open the example sf_bus_demo.

openExample("sf_bus_demo")

In the Property Inspector or Model Explorer, use the data type of the input structure inbus to define the data type of the local structure counterbus_struct.

type(inbus)

Model Explorer showing the specification for the data object counterbus_struct.

Because inbus derives its type from the Simulink.Bus object COUNTERBUS, counterbus_struct also derives its data type from COUNTERBUS.

For more information about this example, see Integrate Custom Structures in Stateflow Charts.

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 value to y.

y = cast(x+3,type(z));

Stateflow chart that uses the type operator.

Input Arguments

expand all

Data name, specified as the name of a Stateflow data object.

Version History

Introduced before R2006a