Main Content

Stateflow.DataType

Data type properties for data and messages

    Description

    Use a Stateflow.DataType object to specify the data type properties for a data object or message.

    Creation

    Each data object and message has its own Stateflow.DataType object. To access the Stateflow.DataType object, use the Props.Type property for the Stateflow.Data or Stateflow.Message object.

    Properties

    expand all

    Stateflow® API objects have properties that correspond to the values you set in the Stateflow Editor. To access or modify a property, use dot notation. To access or modify multiple properties for multiple API objects, use the get and set functions, respectively. For more information, see Modify Properties and Call Functions of Stateflow Objects.

    Method for setting the type of the data object or message, specified as a string scalar or character vector.

    • For local, input, output, or parameter data, use "Inherited", "Built-in", "Bus Object", "Enumerated", "Expression", or "Fixed point".

    • For constant data, use "Built-in", "Expression", or "Fixed point".

    • For data store memory data, use "Inherited".

    • For messages, use "Inherited", "Built-in", "Bus Object", "Enumerated", "Expression", or "Fixed point".

    This property is equivalent to the Mode field of the Data Type Assistant in the Model Explorer and the Data properties dialog box. For more information, see Specify Type of Stateflow Data.

    Name of the Simulink.Bus object that defines the data object or message data, specified as a string scalar or character vector. This property applies only when the Method property of the data object is "Bus Object". For more information, see Access Bus Signals Through Stateflow Structures.

    Name of the enumerated type that defines the data object or message data, specified as a string scalar or character vector. This property applies only when the Method property of the data object is "Enumerated". For more information, see Reference Values by Name by Using Enumerated Data.

    Expression that evaluates to the data type of the data object or message data, specified as a string scalar or character vector. This property applies only when the Method property of the data object is "Expression". For more information, see Specify Data Properties by Using MATLAB Expressions.

    Signedness, specified as a numeric or logical 1 (true) or 0 (false). This property applies only when the Method property of the data object is "Fixed point". For more information, see Fixed-Point Data in Stateflow Charts.

    Word length, in bits, specified as a string scalar or character vector. This property applies only when the Method property of the data object is "Fixed point". For more information, see Fixed-Point Data in Stateflow Charts.

    Fixed-point properties, specified as a Stateflow.FixptType object with these properties:

    • ScalingMode — Method for scaling the fixed-point data object or message data, specified as "Binary point", "Slope and bias", or "None".

    • FractionLength — Fraction length, in bits, specified as a string scalar or character vector. This property applies only when the ScalingMode property is "Binary point".

    • Slope — Slope, specified as a string scalar or character vector. This property applies only when the ScalingMode property is "Slope and bias".

    • Bias — Bias, specified as a string scalar or character vector. This property applies only when the ScalingMode property is "Slope and bias".

    • Lock — Whether to prevent replacement of the fixed-point type with an autoscaled type chosen by the Fixed-Point Tool (Fixed-Point Designer), specified as a numeric or logical 1 (true) or 0 (false).

    This property applies only when the Method property of the data object is "Fixed point". For more information, see Fixed-Point Data in Stateflow Charts.

    Examples

    collapse all

    Access the Stateflow.Props, Stateflow.DataType, and Stateflow.FixptType objects for the Stateflow.Data object x.

    properties = x.Props;
    type = properties.Type;
    fixpt = type.Fixpt;

    Specify the fixed-point properties.

    type.Method = "Fixed point";
    type.Signed = true;
    type.WordLength = "5";
    fixpt.ScalingMode = "Binary point";
    fixpt.FractionLength = "2";
    

    Verify the data type.

    x.DataType
    ans =
        'fixdt(1,5,2)'
    

    Version History

    Introduced before R2006a