Main Content

Stateflow.Data

Data in chart, state, box, or function

    Description

    Use Stateflow.Data objects to store values that are visible at a specific level of the Stateflow® hierarchy. For more information, see Add Stateflow Data and Set Data Properties.

    Creation

    Description

    example

    data = Stateflow.Data(parent) creates a Stateflow.Data object in a parent chart, state, box, or function.

    Input Arguments

    expand all

    Parent for the new data object, specified as a Stateflow API object of one of these types:

    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.

    Interface

    Name of the data object, specified as a character vector.

    Scope of the data object, specified as one of these values:

    • 'Local'

    • 'Input'

    • 'Output'

    • 'Constant'

    • 'Parameter'

    • 'Data Store Memory'

    • 'Temporary'

    • 'Imported'

    • 'Exported'

    For more information, see Scope.

    Port index for the data object, specified as an integer scalar. This property applies only to input and output data. For more information, see Port.

    Method for updating data object, specified as 'Discrete' or 'Continuous'. This property applies only when the ChartUpdate property of the chart that contains the data is 'CONTINUOUS'. For more information, see Continuous-Time Modeling in Stateflow.

    Method for initializing the value of the data object, specified as a character vector that depends on the scope of the data:

    • For local and output data, use 'Expression' or 'Parameter'.

    • For constant data, use 'Expression'.

    • For input data, parameters, and data store memory, use 'Not Needed'.

    To specify the initial value of the data object, use the Props.InitialValue property.

    This property is equivalent to the Initial Value drop-down list in the Model Explorer and the Data properties dialog box. For more information, see Initial Value.

    Whether to save the value of the data object to a variable of the same name in the MATLAB® base workspace at the end of the simulation, specified as a numeric or logical 1 (true) or 0 (false). This property applies only to data in charts that use C as the action language. For more information, see Save Final Value to Base Workspace.

    Whether the data object is a tunable parameter, specified as a numeric or logical 1 (true) or 0 (false). Only tunable parameters can be modified during simulation. This property applies only to parameter data.

    Data Specification

    Type of the data object, specified as a character vector that depends on the Props.Type.Method property of the data object:

    • If the Props.Type.Method property of the data object is 'Inherit', the value of this property is 'Inherit: From definition in chart' for local data and 'Inherit: Same as Simulink' for input, output, and parameter data.

    • If the Props.Type.Method property of the data object is 'Built-in', you can specify this property with one of these options:

      • 'double'

      • 'single'

      • 'int8'

      • 'int16'

      • 'int32'

      • 'int64'

      • 'uint8'

      • 'uint16'

      • 'uint32'

      • 'uint64'

      • 'boolean'

      • 'string'

      • 'ml' (Supported only in charts that use C as the action language)

    • Otherwise, the Props.Type properties of the data object determine the value of this property.

    For more information, see the section Add Data in Create Charts by Using the Stateflow API.

    Data specification properties, specified as a Stateflow.DataProps object with these properties:

    • Type.Method — Method for setting the type of the data object, 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'.

      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.

    • Type.BusObject — Name of the Simulink.Bus object that defines the data object, specified as a character vector. This property applies only when the Type.Method property of the data object is 'Bus Object'. For more information, see Access Bus Signals Through Stateflow Structures.

    • Type.EnumType — Name of the enumerated type that defines the data object, specified as a character vector. This property applies only when the Type.Method property of the data object is 'Enumerated'. For more information, see Reference Values by Name by Using Enumerated Data.

    • Type.Expression — Expression that evaluates to the data type of the data object, specified as a character vector. This property applies only when the Type.Method property of the data object is 'Expression'. For more information, see Specify Data Properties by Using MATLAB Expressions.

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

    • Type.WordLength — Word length, in bits, specified as a character vector. This property applies only when the Type.Method property of the data object is 'Fixed point'. For more information, see Fixed-Point Data in Stateflow Charts.

    • Type.Fixpt.ScalingMode — Method for scaling the fixed-point data object, specified as 'Binary point', 'Slope and bias', or 'None'. This property applies only when the Type.Method property of the data object is 'Fixed point'. For more information, see Fixed-Point Data in Stateflow Charts.

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

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

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

    • Type.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 Type.Method property of the data object is 'Fixed point'.

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

    • Array.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.

    • Array.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.

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

    • InitialValue — Initial value, specified as a character vector. For more information, see Initial Value.

    • Range.Minimum — Minimum value, specified as a character vector. For more information, see Limit Range.

    • Range.Maximum — Maximum value, specified as a character vector. For more information, see Limit Range.

    • ResolveToSignalObject — 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). For more information, see Resolve Data Properties from Simulink Signal Objects.

    • Unit.Name — 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.

    This property is read-only.

    Data size as determined by the compiler, specified as a character vector.

    This property is read-only.

    Data type as determined by the compiler, specified as a character vector.

    Active State Output

    This property is read-only.

    State or chart monitored by the data object, specified as an empty array or a Stateflow.AtomicSubchart, Stateflow.Chart, Stateflow.SimulinkBasedState, Stateflow.State, or Stateflow.StateTransitionTableChart object. For more information, see Monitor State Activity Through Active State Data.

    Signal Logging

    Signal logging properties for the data object, specified as a Stateflow.SigLoggingInfo object with these properties:

    • DataLogging — Whether to enable signal logging, specified as a numeric or logical 1 (true) or 0 (false).

    • DecimateData — Whether to limit the amount of logged data, specified as a numeric or logical 1 (true) or 0 (false).

    • Decimation — Decimation interval, specified as an integer scalar. This property applies only when the DecimateData property is true.

    • LimitDataPoints — Whether to limit the number of data points to log, specified as a numeric or logical 1 (true) or 0 (false).

    • MaxPoints — Maximum number of data points to log, specified as an integer scalar. This property applies only when the LimitDataPoints property is true.

    • NameMode — Source of the signal name, specified as 'SignalName' or 'Custom'.

    • LoggingName — Custom signal name, specified as a character vector. This property applies only when the NameMode property is 'Custom'.

    For more information, see Log Simulation Output for States and Data.

    Example: data.LoggingInfo.DataLogging = true;

    Debugging

    Debugger properties for the data object, specified as a Stateflow.DataDebug object with this property:

    Example: data.Debug.Watch = true;

    Whether to set the data object as a test point, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Monitor Test Points in Stateflow Charts.

    Hierarchy

    This property is read-only.

    Machine that contains the data object, specified as a Stateflow.Machine object.

    This property is read-only.

    Location of the parent of the data object in the model hierarchy, specified as a character vector.

    Identification

    Description for the data object, specified as a character vector.

    Document link for the data object, specified as a character vector.

    User-defined tag for the data object, specified as data of any type.

    This property is read-only.

    Session-independent identifier, specified as an integer scalar. Use this property to distinguish the data object from other objects in the model.

    This property is read-only.

    Unique identifier, specified as an integer scalar. Unlike SSIdNumber, the value of this property is reassigned every time you start a new MATLAB session and may be recycled after an object is deleted.

    Object Functions

    getParentIdentify parent of object
    dialogOpen properties dialog box
    viewDisplay object in editing environment

    Examples

    collapse all

    Add a data object to the chart ch. Specify its name, scope, and data type.

    data = Stateflow.Data(ch);
    data.Name = 'x';
    data.Scope = 'Input';
    data.Props.Type.Method = 'Built-in';
    data.DataType = 'single';

    Compatibility Considerations

    expand all

    Errors starting in R2021b

    Introduced before R2006a