Main Content

type

Type of Stateflow data object

Description

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.

example

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.

Cast the double x to the data type of integer z and assign the value to y.

In a chart that uses C as the action language, enter:

x = -4.56789;
z = int8(5);
y = cast(x,type(z));

Stateflow chart that uses the type operator.

The value of y is -4.

Input Arguments

expand all

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

Version History

Introduced before R2006a