主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

通过编程控制 Scope 模块

此示例显示如何使用编程脚本控制范围。

使用 Simulink 配置对象

使用范围配置对象以编程方式访问范围参数。

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

  • 打开或关闭图例或网格

  • 控制输入的数量

  • 更改显示器数量和活动显示器

创建一个模型并添加一个范围和 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';

找到范围和 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

另请参阅

| |

主题