Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Access Signal Logging Data

View Signal Logging Data

You can view the signal logging data for a paused or completed simulation, using one of these interfaces:

  • The Simulation Data Inspector

  • Programmatically, using MATLAB® commands

View Data in Simulation Data Inspector

You can use the Simulation Data Inspector to view data for signals marked for logging.

  1. Open the model.

  2. Select Simulation > Output > Send Logged Workspace Data to Data Inspector.

  3. Select Simulation > Output > Simulation Data Inspector.

  4. Simulate the model.

For additional information about using the Simulation Data Inspector, see Simulation Data Inspector in Your Workflow.

Signal Logging Object

Simulink® saves signal logging data in a Simulink.SimulationData.Dataset object, which is a MATLAB workspace variable. The default name of the signal logging variable is logsout. You can change the variable name. For details, see Specify a Name for Signal Logging Data.

Releases earlier than R2016a also supported a ModelDataLogs format. For details, see Migrate Scripts That Use ModelDataLogs API.

Access Data Programmatically

You can use the Simulink.SimulationData.Dataset API to access signal logging data programmatically. To access Dataset object elements, use indexing with curly braces. For example, you can access the first element of the topOut signal logging Dataset object using an index.

open_system(docpath(fullfile(docroot,'toolbox','simulink',...
'examples','ex_bus_logging')));
open_system(docpath(fullfile(docroot,'toolbox','simulink',...
'examples','ex_mdlref_counter_bus')));
sim('ex_bus_logging')
topOut
Simulink.SimulationData.Dataset 'topOut' with 4 elements

                         Name          BlockPath                                
                         ____________  ________________________________________ 
    1  [1x1 Signal]      COUNTERBUS    ex_bus_logging/COUNTERBUSCreator        
    2  [1x1 Signal]      OUTPUTBUS     ex_bus_logging/CounterA                 
    3  [1x1 Signal]      INCREMENTBUS  ex_bus_logging/IncrementBusCreator      
    4  [1x1 Signal]      inner_bus     ...erA|ex_mdlref_counter_bus/Bus Creator

  - Use braces { } to access, modify, or add elements using index.
element1 = topOut{1}
element1 = 

  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

  Properties:
              Name: 'COUNTERBUS'
    PropagatedName: ''
         BlockPath: [1x1 Simulink.SimulationData.BlockPath]
          PortType: 'outport'
         PortIndex: 1
            Values: [1x1 struct]


  Methods, Superclasses
element1.Values
ans = 

      data: [1x1 timeseries]
    limits: [1x1 struct]

To search for specific elements in a Dataset object, use the find method. To return the names of the Dataset object elements, use the getNames method.

    Tip:   To call a function on each specified MATLAB timeseries object, you can use the Simulink.SimulationData.forEachTimeseries function. For example, you can use this function to easily resample every element of a structure of timeseries objects obtained by logging a bus signal.

Handling Spaces and Newlines in Logged Names

Signal names in data logs can have spaces or newlines in their names when:

  • The signal is named and the name includes a space or newline character.

  • The signal is unnamed and originates in a block whose name includes a space or newline character.

  • The signal exists in a subsystem or referenced model (or any parent block) whose name includes a space or newline character.

The following three examples show signals whose names contain:

  • A space

  • A signal whose name contains a newline

  • An unnamed signal that originates in a block whose name contains a newline

The following example shows how to handle spaces or new lines in logged names when a model uses the default of logsout for the signal logging data.

logsout
Simulink.SimulationData.Dataset 'logsout' with 3 elements

                         Name  BlockPath            
                         ____  ____________________ 
    1  [1x1 Signal]      ''    untitled/Sine  Wave2
    2  [1x1 Signal]      x y   untitled/Sine Wave  
    3  [1x1 Signal]      x y   untitled/Sine Wave1 

  - Use braces { } to access, modify, or add elements using index.

To access a signal with a space or newline, use the index. For example, to access the x y signal:

>> logsout.getElement(2)
ans = 

  Simulink.SimulationData.Signal
  Package: Simulink.SimulationData

  Properties:
              Name: 'x  y'
    PropagatedName: ''
         BlockPath: [1x1 Simulink.SimulationData.BlockPath]
          PortType: 'outport'
         PortIndex: 1
            Values: [1x1 timeseries]

Access Logged Signal Data in ModelDataLogs Format

Before R2016a, you could log signals in ModelDataLogs format. Starting in R2016a, you cannot log data in the ModelDataLogs format. Signal logging uses the Dataset format.

However, you can use data that was logged in a previous release using ModelDataLogs format.

For more information, see Simulink.ModelDataLogs.

See Also

| | | | | | | |

Related Topics

Was this topic helpful?