Main Content

Logging Intervals

This example shows how to specify logging intervals. Simulink® limits the data logging to the specified intervals.

Open the Example Model

Open the example model, sldemo_mdlref_bus.

Set Logging Intervals

To reduce the amount of logged data, limit data logging to specific simulation time intervals. In this example, you specify two intervals to log the data of two system events triggered by the increment and reset signals. The first interval captures the first reset event. The second interval captures the behavior of the system after the increment event takes place and the signals reach the lower saturation limits. The intervals are based on the increment and reset signal values.

To set the Logging Intervals configuration parameter, in the Simulink Toolstrip, on the Modeling tab, click Model Settings. In the Configuration Parameters dialog box, on the Data Import/Export tab, enable the Logging Intervals parameter by selecting Single simulation output.

The Logging Intervals parameter value must be a real double matrix with two columns. The matrix elements must not be NaN. Each row defines the start and end times for an interval. Intervals must be disjoint and ordered.

For this example, set Logging Intervals to [9,10.5;14.5,30].

Simulate the Model and View Results

Simulate the model.

OUTERDATA is a wide signal with two elements. The scope shows the values of the OUTERDATA signal during simulation. The scope does not honor the Logging Intervals setting.

The Logging Intervals setting is honored when logging time, root outports, signals, data store memory, states, and other kinds of data. To display the logged values of OUTERDATA captured as part of signal logging, use the stem function, which ignores the interpolation settings of the data.

time = out.get('topOut').get('OUTERDATA').Values.Time;
data = out.get('topOut').get('OUTERDATA').Values.Data;
xlabel('Simulation Time');
xlim([0 35]);
ylim([0 45]);

Related Topics