Skip to Main Content Skip to Search
Product Documentation

Configuring a Signal for Signal Logging

Enabling Logging for a Signal

Enable logging for a signal with one of the following techniques:

You can use the Model Explorer to enable signal logging for several signals at once, compared to opening the Signal Properties dialog box repeatedly for each signal that you want to log. However, the Model Explorer:

A signal for which you enable signal logging is a logged signal. By default, Simulink displays a logged signal indicator ( ) for each logged signal.

Using the Signal Properties Dialog Box

  1. In the Model Editor, right-click the signal.

  2. From the context menu, select Signal Properties.

  3. In the Signal Properties dialog box, in the Logging and accessibility tab, select Log signal.

Using the Model Explorer

  1. In the Model Explorer Model Hierarchy pane, select the node that contains the signal for which you want to enable signal logging.

  2. If the Contents pane does not display the DataLogging property, set the Column view to Signals or add the DataLogging property to the current view. For details about column views, see The Model Explorer: Controlling Contents Using Views.

  3. Enable the DataLogging property for one or more signals.

Using the Programmatic Interface

To enable signal logging programmatically for selected blocks, use the outport DataLogging property. Set this property using the set_param command. For example:

  1. At the MATLAB Command Window, open a model. Type

    vdp
  2. Get the port handles of the signal to log. For example, for the Mu block outport signal.

    ph = get_param('vdp/Mu','PortHandles')
  3. Enable signal logging for the desired outport signal.

    set_param(ph.Outport(1),'DataLogging','on')

    The logged signal indicator appears.

Logging Referenced Model Signals

You can log any logged signal in a referenced model. Use the Signal Logging Selector to configure signal logging for a model reference hierarchy. For details, see Models with Model Referencing: Overriding Signal Logging Settings.

If you use the ModelDataLogs signal logging format, then you can also use test points to log data in referenced models (but not for a top-level model). For information about test points, see Designating a Signal as a Test Point. However, MathWorks recommends using the Dataset format for signal logging. For a description of the benefits of using the Dataset format, see Benefits of Using the Dataset Format for Signal Logging. Dataset format does not support using test points for logging in referenced models.

Specifying a Logging Name

You can specify a name, called the logging name, to the object that Simulink uses to store logging data for a signal. Specifying a logging name can be useful for signals that are unnamed or that share a duplicate name with another signal in the model hierarchy. Specifying logging names, rather than using the logging names that Simulink generates, can make the logged data easier to analyze.

To specify a logging name, use one of the following approaches:

If you do not specify a custom logging name, Simulink uses the signal name. If the signal does not have a name, the action Simulink takes depends on the signal logging format:

Using the Signal Properties Dialog Box to Specify a Logging Name

  1. In the Model Editor, right-click the signal.

  2. From the context menu, select Signal Properties.

  3. Specify the logging name:

    1. In the Signal Properties dialog box, select the Logging and accessibility tab.

    2. From the Logging name list, select Custom.

    3. Enter the logging name in the adjacent text field.

Using the Model Explorer to Specify a Logging Name

  1. In the Model Explorer Model Hierarchy pane, select the node that contains the signal for which you want to specify a logging name.

  2. If the Contents pane does not display the LoggingName property, add the LoggingName property to the current view. For details about column views, see The Model Explorer: Controlling Contents Using Views.

  3. Enter a logging name for one or more signals using the LoggingName column.

Programmatically Specifying a Logging Name

Enable signal logging programmatically for selected blocks with the outport DataLogging property. Set this property using the set_param command.

  1. At the MATLAB Command Window, open a model. For example, type:

    vdp
  2. Get the port handles of the signal to log. For example, for the Mu block outport signal:

    ph = get_param('vdp/Mu','PortHandles');
  3. Enable signal logging for the desired outport signal:

    set_param(ph.Outport(1),'DataLogging','on');

    The logged signal indicator appears.

  4. Issue commands that use the DataLoggingNameMode and DataLoggingName parameters. For example:

    set_param(ph.Outport(1),'DataLoggingNameMode','Custom');
    set_param(ph.Outport(1),'DataLoggingName','x2_log');

Limiting the Data Logged for a Signal

You can limit the amount of data logged for a signal by:

For details, see Specifying the Amount of Exported Data.

To limit data logged for a signal, use either the Signal Properties dialog box or the Model Explorer. The following two sections describe how to use each of these interfaces.

Using the Signal Properties Dialog Box to Limit the Amount of Data Logged

  1. In the Model Editor, right-click the signal.

  2. From the context menu, select Signal Properties.

  3. In the Signal Properties dialog box, click the Logging and accessibility tab. Then select one or both of these options:

    • Limit data points to last

    • Decimation

Using the Model Explorer to Limit Data Logged

  1. In the Model Explorer Model Hierarchy pane, select the node that contains the signal for which you want to limit the amount of data logged.

  2. If the Contents pane does not display the DataLoggingDecimation property or the DataLoggingLimitDataPoints property, add one or both of those properties to the current view. For details about column views, see The Model Explorer: Controlling Contents Using Views.

  3. To specify a decimation factor, edit the Decimation and DecimateData properties. To limit the number of samples logged, edit the LimitDataPoints property.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS