%% Logging Intervals
% This example shows how to specify logging intervals. Simulink(R) limits
% the data logging to the specified intervals.

% Copyright 2015-2020 The MathWorks, Inc.

%% Open the Example Model
% Open the example model, |sldemo_mdlref_bus|.

open_system('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.
%
% <<../sldemo_mdlref_bus_scope.png>>
%
% 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 <docid:matlab_ref#btrw_xi-1> 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;
%  stem(time,data,':.');
%  xlabel('Simulation Time');
%  xlim([0 35]);
%  ylabel('OUTERDATA');
%  ylim([0 45]);
%
% <<../sldemo_mdlref_bus_stem.png>>