%% Modify _x_-axis of Scope
% This example shows how to modify the _x_-axis values of the Scope block
% using the *Time span* and *Time display offset* parameters. The *Time
% span* parameter modifies how much of the simulation time is shown and
% offsets the _x_-axis labels. The *Time display offset* parameter modifies the
% labels used on the _x_-axis.
%%
% You can also use this procedure for the Time Scope block, Floating Scope
% block, or Scope viewer.

% Copyright 2020 The MathWorks, Inc. 

%% 
% Open the model and run the simulation to see the original scope
% output. The simulation runs for 10 time steps stepping up by 1 at each
% time step.
%%
model = 'ModifyScopeXAxis';
open_system(model);
sim(model);
open_system([model,'/Scope']);

%% Modify Time Span Shown
% Modify the *Time span* parameter to 2. You can follow the
% commands below, or in the Scope window, click the Configuration
% Properties button and navigate to the Time tab.
scopeConfig = get_param([model,'/Scope'],'ScopeConfiguration');
scopeConfig.TimeSpan = '2';
sim(model);
open_system([model,'/Scope']);

%%
% The _x_-axis of the scope now shows only the last 2 time steps and
% offsets the _x_-axis labels to show 0-2. The bottom toolbar shows
% that the _x_-axis is offset by 8. This offset is different from the *Time
% display offset* value.
%
% The *Time span* parameter is useful if you do not want to visualize
% signal initialization or other start-up tasks at the beginning of a
% simulation. You can still see the full simulation time span if you click
% the *Span x-axis* button.

%% Offset _x_-axis Labels
% Modify the *Time display offset* parameter to 5. Again, use the
% commands below, or in the Scope window, click the Configuration
% Properties button and navigate to the Time tab.
scopeConfig.TimeDisplayOffset = '5';
sim(model);
open_system([model,'/Scope']);
%%
% Now, the same time span of 2 is show in the scope, but the _x_-axis labels are
% offset by 5, starting at 5 and ending at 7. If you click the *Span
% x-axis* button, the _x_-axis labels still start at 5.