主要内容

以编程方式控制 Scope 模块

此示例说明如何使用编程脚本控制示波器。

使用 Simulink 配置对象

使用示波器配置对象以编程方式访问示波器参数。

  • 修改标题、轴标签和轴范围

  • 打开或关闭图例或网格

  • 控制输入数目

  • 更改显示画面的数量以及哪个显示画面处于活动状态

创建一个模型并添加 Scope 和 Time Scope 模块。然后,使用 get_param 创建示波器配置对象 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')
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'

设置属性。

myConfiguration.DataLoggingMaxPoints ='10000';

查找 Scope 和 Time Scope 模块。

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on', ...
'AllBlocks','on','BlockType','Scope')
ans = 2×1 cell
    {'myModel/myScope'    }
    {'myModel/myTimeScope'}

仅查找 Simulink Scope 模块。

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'Simulink.scopes.TimeScopeBlockCfg')
ans = 1×1 cell array
    {'myModel/myScope'}

仅查找 DSP Time Scope 模块。

find_system(mdl,'LookUnderMasks','on','IncludeCommented','on',...
'AllBlocks','on','BlockType','Scope','DefaultConfigurationName',...
'spbscopes.TimeScopeBlockCfg')
ans = 1×1 cell array
    {'myModel/myTimeScope'}

示波器配置属性

有关示波器配置对象属性的详细信息,请参阅 TimeScopeConfiguration

另请参阅

| |

主题