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

    Properties

    expand all

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

    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.

    Initial value of the data object, specified as a character vector. For more information, see Initial Value.

    Example: data.Props.InitialValue = '1.5';

    Maximum value for the data object, specified as a character vector. For more information, see Limit Range.

    Example: data.Props.Range.Maximum = '1024';

    Minimum value for the data object, specified as a character vector. For more information, see Limit Range.

    Example: data.Props.Range.Minimum = '0';

    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.

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

    Example: data.Props.Complexity = 'On';

    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.

    Example: data.Props.ResolveToSignalObject = true;

    Unit of measurement for the data object, specified as a character vector. This property applies only to data in charts that use C as the action language. For more information, see Specify Units for Stateflow Data.

    Example: data.Props.Unit.Name = 'm';

    Data Type

    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'

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

      • 'string' (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.

    Method for setting the data type, specified as a character vector that depends on the scope of the data:

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

    Example: data.Props.Method = 'Built-in';

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

    Example: data.Props.Type.BusObject = 'COUNTERBUS';

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

    Example: data.Props.Type.EnumType = 'BasicColors';

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

    Example: data.Props.Type.Expression = 'type(y)';

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

    Example: data.Props.Type.Signed = false;

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

    Example: data.Props.Type.WordLength = '32';

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

    Example: data.Props.Type.Fixpt.ScalingMode = 'Binary point';

    Fraction length, in bits, of the fixed-point data object, specified as a character vector. This property applies only to fixed-point data when the Props.Type.Fixpt.ScalingMode property is 'Binary point'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: data.Props.Type.Fixpt.FractionLength = '2';

    Slope of the fixed-point data object, specified as a character vector. This property applies only to fixed-point data when the Props.Type.Fixpt.ScalingMode property is 'Slope and bias'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: data.Props.Type.Fixpt.Slope = '2^-2';

    Bias of the fixed-point data object, specified as a character vector. This property applies only to fixed-point data when the Props.Type.Fixpt.ScalingMode property is 'Slope and bias'. For more information, see Fixed-Point Data in Stateflow Charts.

    Example: data.Props.Type.Fixpt.Bias = '0';

    Whether to prevent replacement of the fixed-point type of the data object with an autoscaled type chosen by the Fixed-Point Tool (Fixed-Point Designer), specified as a numeric or logical 1 (true) or 0 (false). For more information, see Autoscaling Using the Fixed-Point Tool (Fixed-Point Designer).

    Example: data.Props.Type.Fixpt.Lock = true;

    This property is read-only.

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

    Data Size

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

    Whether the data object has variable size, specified as a numeric or logical 1 (true) or 0 (false). Only variable-size data can change size during simulation. This property applies only to input and output data and is equivalent to the Variable Size check box in the Data properties dialog box. For more information, see Declare Variable-Size Data in Stateflow Charts.

    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.

    This property is read-only.

    Data size 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

    Whether to enable signal logging for the data object, specified as a numeric or logical 1 (true) or 0 (false). For more information, see Log Simulation Output for States and Data.

    Example: data.LoggingInfo.DataLogging = true;

    Whether to limit the amount of logged data, specified as a numeric or logical 1 (true) or 0 (false). When this property is true, signal logging skips samples by using the interval size specified by the LoggingInfo.Decimation property. For more information, see Decimation.

    Example: data.LoggingInfo.DeimateData = true;

    Decimation interval, specified as an integer scalar. The default value of 2 means that the chart logs every other sample. For more information, see Decimation.

    Example: data.LoggingInfo.Decimation = 5;

    Whether to limit the number of data points to log, specified as a numeric or logical 1 (true) or 0 (false). When this property is true, signal logging limits the number of data points by using the value specified by the LoggingInfo.MaxPoints property. For more information, see Limit Data Points to Last.

    Example: data.LoggingInfo.LimitDataPoints = true;

    Maximum number of data points to log, specified as an integer scalar. The default value of 5000 means the chart logs the last 5000 data points generated by the simulation. For more information, see Limit Data Points to Last.

    Example: data.LoggingInfo.MaxPoints = 100;

    Source of the signal name used to log the data object, specified as one of these values:

    • 'SignalName' — Use the name of the data object.

    • 'Custom' — Use the custom signal name specified by the LoggingInfo.LoggingName property.

    For more information, see Logging Name.

    Example: data.LoggingInfo.NameMode = 'Custom';

    Custom signal name used for logging the data object, specified as a character vector. This property applies only when the LoggingInfo.NameMode property is 'Custom'. For more information, see Logging Name.

    Example: data.LoggingInfo.LoggingName = 'Data';

    Debugging

    Whether to track the value of the data object in the Breakpoints and Watch window, specified as a numeric or logical 1 (true) or 0 (false). For more information, see View Data in the Breakpoints and Watch Window.

    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

    classhandleProvide class handle for object
    dialogOpen properties dialog box
    getReturn MATLAB structure containing property settings of object or array of objects
    setSet properties with specified values
    upReturn parent of object
    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';
    Introduced before R2006a