Main Content

Stateflow.SimulationData.Data

Logged Stateflow data values

Description

Use Stateflow.SimulationData.Data objects to view logged Stateflow® data from local and output data.

Creation

  1. In the Symbols pane, select a local or output data object.

  2. In the Property Inspector, under Logging, select the Log signal data check box.

  3. Simulate the model. The signal logging object generated in the MATLAB® workspace contains the Stateflow.SimulationData.Data object. Specify the name of the signal logging object using the Signal logging (Simulink) model configuration parameter.

Properties

expand all

Logging name of the data object, specified as a character array. By default, the value of this property is the same as the Name property of the Stateflow.Data object associated with this Stateflow.SimulationData.Data object.

Data Types: char

Block path for the source block, specified as a Simulink.SimulationData.BlockPath (Simulink) object.

Data Types: Simulink.SimulationData.BlockPath

Logged data and time, specified as a timeseries object.

Data Types: timeseries

Object Functions

plot (Simulink)Plot data in Simulation Data Inspector

Examples

collapse all

  1. Open the shift_logic Stateflow chart of the sf_car model.

    openExample("sf_car")
    open_system("sf_car/shift_logic", "force")
  2. Open the Symbols pane. In the Simulation tab, in the Prepare section, click Symbols Pane.

  3. Open the Property Inspector. In the Simulation tab, in the Prepare section, click Property Inspector.

  4. Configure the up_th local data for logging.

    • In the Symbols pane, select up_th.

    • In the Property Inspector, in the Logging section, select the Log signal data check box.

  5. Simulate the model.

  6. To access the Stateflow data logging object, at the MATLAB command prompt, enter:

    sigsOut
    sigsOut = 
    
    Simulink.SimulationData.Dataset 'sigsOut' with 1 element
    
                            Name         BlockPath                        
                            ___________  ________________________________ 
        1  [1x1 Data ]      up_th      sf_car/shift_logic

  7. To access the logged data, use the get (Simulink) function.

    up_thLog = sigsOut.get("up_th")
    up_thLog = 
    
      Stateflow.SimulationData.Data
      Package: Stateflow.SimulationData
    
      Properties:
             Name: 'up_th'
        BlockPath: [1×1 Simulink.SimulationData.BlockPath]
           Values: [1×1 timeseries]
    

  8. To access the logged data and time of each logged element, use the Values.Data and Values.Time properties. Arrange logged data in tabular form by using the table function.

    T = table(up_thLog.Values.Time,up_thLog.Values.Data);
    T.Properties.VariableNames = ["Time" "Data"]
    T =
    
      2501×2 table
    
           Time       Data
        __________    ____
    
         0       0
         0.04    27.227
         0.08    27.204
         0.12    27.182
         0.16    27.159
          0.2    27.136
         0.24    27.113
         0.28     27.09
         0.32    27.067
    
          :        :   
    
        99.68        50
        99.72        50
        99.76        50
         99.8        50
        99.84        50
        99.88        50
        99.92        50
        99.96        50
          100        50
    In this example, the data points with values of 0 correspond to when the chart initializes the local data up_th to 0 at time 0.

Tips

  • Stateflow.SimulationData.Data objects record a data point every time that the Stateflow chart writes to the data, even if the data does not change value.

  • For multiple writes in the same time step to the same data, Stateflow logs both writes as two separate entries.

Version History

Introduced in R2017b