Control Scope Blocks Programmatically

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

In this example, the variable myConfiguration stores the mask object obtained using get_param. The example also shows how to change the value of a Scope parameter.

Create a New Model

mdl='myModel';
new_system(mdl);

Add Scope and Time Scope Blocks to Model

add_block('simulink/Sinks/Scope', [mdl '/myScope']);
add_block('dspsnks4/Time Scope', [mdl '/myTimeScope']);

Get a Scope Configuration Object

Many of the scope configuration properties correspond to Scope block parameters.

myConfiguration = get_param([mdl '/myScope'],'ScopeConfiguration')
myConfiguration = 

  Scope Configuration with properties:
                         
                                Name: 'myScope'
                            Position: [680 390 560 420]
                             Visible: 0
               OpenAtSimulationStart: 0
                     DisplayFullPath: 0
    PreserveColorsForCopyToClipboard: 0
                       NumInputPorts: '1'
                    LayoutDimensions: [1 1]
                          SampleTime: '-1'
                FrameBasedProcessing: 0
                        MaximizeAxes: 'Off'
                    MinimizeControls: 0
                         AxesScaling: 'Manual'
               AxesScalingNumUpdates: '10'
                            TimeSpan: 'Auto'
               TimeSpanOverrunAction: 'Wrap'
                           TimeUnits: 'none'
                   TimeDisplayOffset: '0'
                      TimeAxisLabels: 'Bottom'
                   ShowTimeAxisLabel: 0
                       ActiveDisplay: 1
                               Title: '%<SignalLabel>'
                          ShowLegend: 0
                            ShowGrid: 1
                PlotAsMagnitudePhase: 0
                             YLimits: [-10 10]
                              YLabel: ''
                         DataLogging: 0
             DataLoggingVariableName: 'ScopeData'
          DataLoggingLimitDataPoints: 0
                DataLoggingMaxPoints: '5000'
             DataLoggingDecimateData: 0
               DataLoggingDecimation: '2'
               DataLoggingSaveFormat: 'Dataset'

Set a Property

myConfiguration.DataLoggingMaxPoints ='10000';

Find Scope and Time Scope Blocks

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

ans = 
    'myModel/myScope'
    'myModel/myTimeScope'

Find Only Simulink Scope Blocks

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'Simulink.scopes.TimeScopeBlockCfg')
ans = 
    'myModel/myScope'

Find Only DSP System Toolbox Time Scope Blocks

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'spbscopes.TimeScopeBlockCfg')
ans = 
    'myModel/myTimeScope'

Scope Configuration Properties

See TimeScopeConfiguration

See Also

| |

Related Topics