%% Save Simulation Data Using Scope Block
% This example shows how to save signals to the MATLAB Workspace using the
% Scope block. You can us these steps for the Scope or Time Scope blocks. 
% To save data from the Floating Scope or Scope viewer, see
% <docid:simulink_ug#buuycvu-1>.

% Copyright 2019 The MathWorks, Inc.

%% 
% Using the |vdp| model, turn on data logging to the workspace.  You can
% follow the commands below, or in the Scope window, click the
% Configuration Properties button and navigate to the Logging tab, turn on
% *Log data to workspace*.
%%
vdp
scopeConfig = get_param('vdp/Scope','ScopeConfiguration');
scopeConfig.DataLogging = true;
scopeConfig.DataLoggingSaveFormat = 'Dataset';
out = sim('vdp');
%% 
% In the MATLAB Command window, view the logged data from the
% |out.ScopeData| structure. 
%%
x1_data = out.ScopeData{1}.Values.Data(:,1);
x1_time = out.ScopeData{1}.Values.Time;
plot(x1_time,x1_data)