Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Access Logged Data

Signal Logging Object

During simulation, Stateflow® saves logged data in a signal logging object, which you can access in the MATLAB® workspace. The type of signal logging object depends on the signal logging format that you choose.

FormatSignal Logging Object
DatasetSimulink.SimulationData.Dataset
ModelDataLogsSimulink.ModelDataLogs

The default name of the signal logging object is logsout.

See Also

Access Logged Data Saved in Dataset Format

The following procedure explains how to access logged data in Dataset format for any chart. For example, try the procedure with the sf_semantics_hotel_checkin model, which uses a chart to simulate a hotel check-in process. To open the model, click sf_semantics_hotel_checkinsf_semantics_hotel_checkin or type sf_semantics_hotel_checkin at the MATLAB command prompt. Enable logging as described in Configure States and Local Data for Logging.

  1. View the signal logging object in the MATLAB environment.

    For example:

    1. Start simulating the sf_semantics_hotel_checkin model using the Dataset signal logging format.

    2. When the Front_desk state becomes active, check in to the hotel by toggling the first switch.

    3. When the Bedroom state in the Executive_suite state becomes active, order room service multiple times, for example, by toggling the second switch 10 times.

    4. Stop simulation.

    5. Enter:

      logsout

      Result:

        Simulink.SimulationData.Dataset
        Package: Simulink.SimulationData
      
        Characteristics:
                    Name: 'logsout'
          Total Elements: 2
      
        Elements:
          1: 'Dining_Room'
          2: 'service'

      The output indicates:

      • logsout is a Simulink® object of type SimulationData.Dataset.

      • Two elements were logged.

  2. Use the getElement method to access logged elements by index and by name.

    For example:

    • To access logged activity for the Check_in.Checked_in.Executive_suite.Dining_area state:

      By:Enter:
      Indexlogsout.getElement(1)
      Namelogsout.getElement('Dining_Room')
      Block path
      1. logsout.getElement(1).BlockPath

        Returns:

        • Block Path: 'sf_semantics_hotel_checkin/Hotel'

        • SubPath: 'Check_in.Checked_in.Executive_suite.Dining_area'

      2. bp = Simulink.BlockPath('sf_semantics_hotel_checkin/Hotel');

      3. bp.SubPath = 'Check_in.Checked_in.Executive_suite.Dining_area';

      4. logsout.getElement(bp)

      The result is a Stateflow.SimulationData.State object:

        Stateflow.SimulationData.State
        Package: Stateflow.SimulationData
      
        Properties:
               Name: 'Dining_Room'
          BlockPath: [1x1 Simulink.SimulationData.BlockPath]
             Values: [1x1 timeseries]
      
    • To access logged activity for the service local data:

      By:Enter:
      Indexlogsout.getElement(2)
      Namelogsout.getElement('service')
      Block path
      1. logsout.getElement(2).BlockPath

        Returns:

        • Block Path: 'sf_semantics_hotel_checkin/Hotel'

        • SubPath: 'service'

      2. bp = Simulink.BlockPath('sf_semantics_hotel_checkin/Hotel');

      3. bp.SubPath = 'service';

      4. logsout.getElement(bp)

      The result is a Stateflow.SimulationData.Data object:

         Stateflow.SimulationData.Data
        Package: Stateflow.SimulationData
      
        Properties:
               Name: 'service'
          BlockPath: [1x1 Simulink.SimulationData.BlockPath]
             Values: [1x1 timeseries]

    The logged values for Stateflow.SimulationData.State and Stateflow.SimulationData.Data objects are stored in the Values property as Simulink objects of type Timeseries.

  3. Access logged data and time through the Values property.

    For example:

    For:Enter:
    Datalogsout.getElement(1).Values.Data;
    Timelogsout.getElement(1).Values.Time;

  4. View the logged data.

    See View Logged Data.

Was this topic helpful?