Control Time Scope Programmatically

Use Simulink.scopes.TimeScopeConfiguration

Use instances of Simulink.scopes.TimeScopeConfiguration to programmatically affect the Time Scope display.

  • 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 htsc stores the mask object obtained using get_param. The example also shows how to change a scope parameter, such as MaximizeAxes.

add_block('built-in/TimeScope',[mdl '/Scope'])
htsc = get_param([mdl '/Scope'],'ScopeConfiguration')
htsc = 

  TimeScopeConfiguration with properties:

                          Name: 'Scope'
                 NumInputPorts: '1'
                  BufferLength: '5000'
                    SampleTime: '-1'
         OpenAtSimulationStart: 0
                       Visible: 0
                      Position: [680 390 560 420]
                  MaximizeAxes: 'Off'
                   AxesScaling: 'Manual'
                      TimeSpan: 'Auto'
         TimeSpanOverrunAction: 'Wrap'
                     TimeUnits: 'none'
             TimeDisplayOffset: '0'
                TimeAxisLabels: 'Bottom'
              LayoutDimensions: [1 1]
                 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'
htsc.MaximizeAxes ='On';

Time Scope Configuration Parameters

The predefined parameters associated with a Time Scope Configuration are defined in Simulink.scopes.TimeScopeConfiguration.

Was this topic helpful?