| Contents | Index |
| On this page… |
|---|
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:
Does not display unnamed signals
Might need to be reconfigured to display the DataLogging property (which sets up logging for a signal)
A signal for which you enable signal logging is a logged
signal. By default, Simulink displays a logged signal
indicator (
) for each logged signal.
In the Model Editor, right-click the signal.
From the context menu, select Signal Properties.
In the Signal Properties dialog box, in the Logging and accessibility tab, select Log signal.
Note The only signals that Model Explorer displays are named signals. See Signal Names. |
In the Model Explorer Model Hierarchy pane, select the node that contains the signal for which you want to enable signal logging.
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.
Enable the DataLogging property for one or more signals.
To enable signal logging programmatically for selected blocks, use the outport DataLogging property. Set this property using the set_param command. For example:
At the MATLAB Command Window, open a model. Type
vdp
Get the port handles of the signal to log. For example, for the Mu block outport signal.
ph = get_param('vdp/Mu','PortHandles')Enable signal logging for the desired outport signal.
set_param(ph.Outport(1),'DataLogging','on')
The logged signal indicator appears.
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.
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.
Note The logging name is for a specific signal. The logging name is distinct from the signal logging name, which is the name for the object containing all the logged signal data for a model. The default signal logging name is logsout. For details about the signal logging name, see Specifying a Name for the Signal Logging Data. |
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:
Dataset — Uses a blank name
ModelDataLogs — Generates a default name that is composed of the block name and port number. For example, if the block name is MyBlock and the signal being logged is the first output of this block, Simulink generates the name SL_MyBlock1.
In the Model Editor, right-click the signal.
From the context menu, select Signal Properties.
Specify the logging name:
In the Signal Properties dialog box, select the Logging and accessibility tab.
From the Logging name list, select Custom.
Enter the logging name in the adjacent text field.
In the Model Explorer Model Hierarchy pane, select the node that contains the signal for which you want to specify a logging name.
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.
Enter a logging name for one or more signals using the LoggingName column.
Enable signal logging programmatically for selected blocks with the outport DataLogging property. Set this property using the set_param command.
At the MATLAB Command Window, open a model. For example, type:
vdp
Get the port handles of the signal to log. For example, for the Mu block outport signal:
ph = get_param('vdp/Mu','PortHandles');Enable signal logging for the desired outport signal:
set_param(ph.Outport(1),'DataLogging','on');
The logged signal indicator appears.
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');
You can limit the amount of data logged for a signal by:
Specifying a decimation factor
Limiting the number of samples saved to be only the most recent samples
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.
In the Model Editor, right-click the signal.
From the context menu, select Signal Properties.
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
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.
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.
To specify a decimation factor, edit the Decimation and DecimateData properties. To limit the number of samples logged, edit the LimitDataPoints property.
![]() | Exporting Signal Data Using Signal Logging | Viewing the Signal Logging Configuration | ![]() |

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 |