This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Type Stateflow Data

What Is Data Type?

The term data type refers to the way computers represent numbers in memory. The type determines the amount of storage allocated to data, the method of encoding a data value as a pattern of binary digits, and the operations available for manipulating the data.

Specify Data Type with the Property Inspector

To specify the data type in the editor:

  1. Open the Symbols and Property Inspector windows from the View menu.

  2. Select the data object row in the Symbols window.

  3. In the Property Inspector, enter the data type directly in the Type field, or select it from the Type drop-down list.

Specify Data Type with the Data Type Assistant

To specify the type of a Stateflow® data object with the Data Type Assistant:

  1. Open the Data properties dialog box.

  2. Click the Data Type Assistant button.

  3. Choose a Mode in the Data Type Assistant section of the dialog box.

    You can choose from these modes for each scope.

    ScopeData Type Modes
     InheritBuilt inFixed pointEnumeratedExpressionBus Object

    For charts that use MATLAB as the action language, yes































    Data Store Memory


  4. Based on the mode you select, specify a data type.

    ModeWhat To Specify


    You cannot specify a value. You inherit the data type based on the scope you select for the data object:

    Built in

    Select a data type from the drop-down list of supported data types, as described in Built-In Data Types.

    Fixed point

    Specify the following information about the fixed-point data:

    • Whether the data is signed or unsigned

    • Word length

    • Scaling mode

    For information on how to specify these fixed-point data properties, see Fixed-Point Data Properties.


    Specify the class name for the enumerated data type. For more information, see Define Enumerated Data in a Chart.


    Enter an expression that evaluates to a data type in the Type field. You can use these expressions:

    For more information on how to build expressions in the Data properties dialog box, see Enter Expressions and Parameters for Data Properties.

    Bus object

    In the Bus object field, enter the name of a Simulink.Bus object to associate with the Stateflow bus object structure. You must define the bus object in the base workspace. If you have not yet defined a bus object, click Edit to create or edit a bus object in the Bus Editor.

      Note:   You can also inherit bus object properties from Simulink signals.

  5. Click Apply to save the data type settings.

    Note:   The Data Type Assistant is available only with the Data properties dialog box. It is not available with the Symbols window.

Built-In Data Types

You can choose from these built-in data types:

Data Type



64-bit double-precision floating point


32-bit single-precision floating point


32-bit signed integer


16-bit signed integer


8-bit signed integer


32-bit unsigned integer


16-bit unsigned integer


8-bit unsigned integer


Boolean (1 = true; 0 = false)


Typed internally with the MATLAB array mxArray. The ml data type provides Stateflow data with the benefits of the MATLAB environment, including the ability to assign the Stateflow data object to a MATLAB variable or pass it as an argument to a MATLAB function. See ml Data Type.

    Note:   ml data cannot have a scope outside the Stateflow hierarchy; that is, it cannot have a scope of Input to Simulink or Output to Simulink.

Inherit Data Types from Simulink Objects

Stateflow data objects of scope Input, Output, Parameter, and Data Store Memory can inherit their data types from Simulink objects, as follows:

Scope:Can inherit type from:
InputSimulink input signal connected to corresponding input port in chart
OutputSimulink output signal connected to corresponding output port in chart
ParameterCorresponding MATLAB workspace variable or Simulink parameter in a masked subsystem
Data Store MemoryCorresponding Simulink data store

To configure these objects to inherit data types, create the corresponding objects in the Simulink model, and then select Inherit: Same as Simulink from the Type drop-down list in the Data properties dialog box. For more information, see Specify Data Type with the Data Type Assistant.

To determine the data types that the objects inherit, build the Simulink model and look at the Compiled Type column for each Stateflow data object in the Model Explorer.

Derive Data Types from Previously Defined Data

You can use the type operator to derive data types from previously defined Stateflow data. In the following example, the expression type(inbus) specifies the data type of the Stateflow structure counterbus_struct, where inbus is defined by the Simulink.Bus object COUNTERBUS. Therefore, the structure counterbus_struct also derives its data type from the bus object COUNTERBUS.

After you build your model, the Compiled Type column of the Model Explorer shows the type of each data object in the compiled simulation application. For more information, see type Operator.

Type Data by Using an Alias

You can specify the type of Stateflow data by using a Simulink data type alias (see Simulink.AliasType in the Simulink Reference documentation). Suppose that you define a data type alias named MyFloat as follows:

MyFloat = Simulink.AliasType;
MyFloat.BaseType = 'single';

In the following example, the data y has the same type as MyFloat.

After you build your model, the Compiled Type column of the Model Explorer shows the type used in the compiled simulation application.

Strong Data Typing with Simulink I/O

By default, inputs to and outputs from charts are of type double. Input signals from Simulink models convert to the type of the corresponding input data objects in charts. Likewise, the data output objects convert to double before they are exported as output signals to Simulink models.

To interface directly with signals of data types other than double without the need for conversion, select Use Strong Data Typing with Simulink I/O in the chart properties. The chart accepts input signals of any data type that Simulink supports, as long as the data type of the input signal matches the type of the corresponding Stateflow data object. Otherwise, you receive a type mismatch error.

    Note:   For fixed-point data, select Use Strong Data Typing with Simulink I/O to flag mismatches between input or output fixed-point data in charts and their counterparts in Simulink models.

Related Topics

Was this topic helpful?