Main Content

Stateflow.DataProps

Data specification properties for data and messages

    Description

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

    Creation

    Each data object and message has its own Stateflow.DataProps object. To access the Stateflow.DataProps object, use the Props 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.

    Data type properties, specified as a Stateflow.DataType object with these properties:

    • Method — Method for setting the type of the data object or message, specified as a 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.

    • BusObject — Name of the Simulink.Bus object that defines the data object or message data, specified as a 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.

    • EnumType — Name of the enumerated type that defines the data object or message data, specified as a 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 — Expression that evaluates to the data type of the data object or message data, specified as a 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.

    • Signed — 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.

    • WordLength — Word length, in bits, specified as a 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.

    • Fixpt.ScalingMode — Method for scaling the fixed-point data object or message data, specified as 'Binary point', 'Slope and bias', or 'None'. 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.

    • Fixpt.FractionLength — Fraction length, in bits, specified as a character vector. This property applies only when the Method property is 'Fixed point' and the Fixpt.ScalingMode property is 'Binary point'.

    • Fixpt.Slope — Slope, specified as a character vector. This property applies only when the Method property is 'Fixed point' and the Fixpt.ScalingMode property is 'Slope and bias'.

    • Fixpt.Bias — Bias, specified as a character vector. This property applies only when the Method property is 'Fixed point' and the Fixpt.ScalingMode property is 'Slope and bias'.

    • Fixpt.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'.

    Array properties, specified as a Stateflow.DataArray object with these properties:

    • Size — Size of the data object or message data, specified as a character vector. For more information, see Specify Size of Stateflow Data.

    • IsDynamic — Whether the data object has variable size, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to input, output, and local data and is equivalent to the Variable Size check box in the Property Inspector, the Model Explorer, or the Data properties dialog box. Use the Size property to specify the maximum size for the data. For more information, see Declare Variable-Size Data in Stateflow Charts.

    • FirstIndex — Index for the first element of the array data object, specified as a character vector. This property applies only to array data in charts that use C as the action language. For more information, see Save Final Value to Base Workspace.

    Whether the data object or message accepts complex values, specified as 'On' or 'Off'. For more information, see Complex Data in Stateflow Charts.

    Initial value, specified as a character vector.

    Range of acceptable values for the data object, specified as a Stateflow.DataRange object with these properties:

    • Minimum — Minimum value, specified as a character vector.

    • Maximum — Maximum value, specified as a character vector.

    This property does not apply to message data. For more information, see Limit Range.

    Whether the data object resolves to a Simulink.Signal object that you define in the model or base workspace, specified as a numeric or logical 1 (true) or 0 (false). This property does not apply to message data. For more information, see Resolve Data Properties from Simulink Signal Objects.

    Unit of measurement for input and output data objects, specified as a Stateflow.Unit object with this property:

    • Name — Name of the unit of measurement, specified as a character vector.

    This property applies only to input and output data. For more information, see Specify Units for Stateflow Data.

    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)'
    

    Access the Stateflow.Props and Stateflow.DataArray objects for the Stateflow.Data object x.

    properties = x.Props;
    array = properties.Array;

    Specify the size of the data object.

    array.size = "[2 3]";

    Access the Stateflow.Props and Stateflow.DataRanges objects for the Stateflow.Data object x.

    properties = x.Props;
    range = properties.Range;

    Specify the minimum and maximum acceptable values.

    range.Minimum = "0";
    range.Maximum = "1024";

    Access the Stateflow.Props and Stateflow.Unit objects for the Stateflow.Data object x.

    properties = x.Props;
    unit = properties.Unit;

    Specify the units as meters.

    unit.Name = "m";
    Introduced before R2006a