This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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


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', ...

ans = 

Find Only Simulink Scope Blocks

ans = 

Find Only DSP System Toolbox Time Scope Blocks

ans = 

Scope Configuration Properties

See TimeScopeConfiguration

See Also

| |

Related Topics