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';
add_block('simulink/Sinks/Scope', [mdl '/myScope']);
add_block('dspsnks4/Time Scope', [mdl '/myTimeScope']);
myConfiguration = get_param([mdl '/myScope'],'ScopeConfiguration')
myConfiguration = 
Scope configuration with properties:

                                Name: 'myScope'
                            Position: [360 302 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 the Scope and Time Scope blocks.

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on', ...
ans = 2x1 cell
    {'myModel/myScope'    }

Find only Simulink Scope blocks.

ans = 1x1 cell array

Find only the DSP Time Scope blocks.

ans = 1x1 cell array

Scope Configuration Properties

For details about the Scope Configuration object properties, see TimeScopeConfiguration.

See Also

| |

Related Topics