%% Control Scope Blocks Programmatically
% This example shows how to control scopes with programming scripts.
%% Use Simulink Configuration Object
% Use a Scope Configuration object for programmatic access to scope parameters.
% Modify the title, axis labels, and axis limits
% Turn on or off the legend or grid
% Control the number of inputs
% Change the number of displays and which display is active
% Create a model and add a Scope and Time Scope block. Then, use get_param to create the Scope Configuration object myConfiguration.

mdl = 'myModel';
new_system(mdl);
add_block('simulink/Sinks/Scope', [mdl '/myScope']);
add_block('dspsnks4/Time Scope', [mdl '/myTimeScope']);
myConfiguration = get_param([mdl '/myScope'],'ScopeConfiguration')

%
% Set a property.

myConfiguration.DataLoggingMaxPoints ='10000';

%
% Find the Scope and Time Scope blocks.

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on', ...
'AllBlocks','on','BlockType','Scope')

%
% Find only Simulink Scope blocks.

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'Simulink.scopes.TimeScopeBlockCfg')

%
% Find only the DSP Time Scope blocks.

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'spbscopes.TimeScopeBlockCfg')

%
%% Scope Configuration Properties
% For details about the Scope Configuration object properties, see TimeScopeConfiguration.
% Copyright 2019 The MathWorks, Inc.