execute
(将删除)收集度量数据
以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅Migrating from Metrics Dashboard to Model Maintainability Dashboard。
说明
为指定的度量引擎对象收集模型度量数据。模型度量数据基于已定义的架构组件。组件是以下 Simulink 对象:
模型
Subsystem 模块
图
MATLAB Function 模块
受保护模型
execute( 收集可用模型度量的度量数据,其中可包括 MathWorks 度量和自定义度量。metric_engine)
输入参数
创建一个 slmetric.Engine 对象。
metric_engine = slmetric.Engine();
模型度量或您创建的自定义模型度量的度量标识符。您可以指定一个或多个度量标识符。您可以通过调用 slmetric.metric.getAvailableMetrics 获得度量标识符。
示例: 'mathworks.metrics.DescriptiveBlockNames'
示例
收集和访问模型 sldemo_mdlref_basic 的模型度量数据。
打开模型。
openExample('sldemo_mdlref_basic'); 创建一个 slmetric.Engine 对象,并设置要进行分析的模型的根。
metric_engine = slmetric.Engine(); % Include referenced models and libraries in the analysis. % These properties are on by default. metric_engine.ModelReferencesSimulationMode = 'AllModes'; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
收集模型度量数据
execute(metric_engine);
获取返回一个 slmetric.metric.ResultCollection 对象数组 res_col 的模型度量数据。
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
显示 mathworks.metrics.SimulinkBlockCount 度量的结果。
for n=1:length(res_col)
if res_col(n).Status == 0
result = res_col(n).Results;
for m=1:length(result)
disp(['MetricID: ',result(m).MetricID]);
disp([' ComponentPath: ', result(m).ComponentPath]);
disp([' Value: ', num2str(result(m).Value)]);
disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]);
end
else
disp(['No results for:', result(n).MetricID]);
end
disp(' ');
end收集和访问模型 sldemo_mdlref_basic 的模型度量数据。
打开模型。
openExample('sldemo_mdlref_basic'); 创建一个 slmetric.Engine 对象。在分析中包括引用的模型和库,并设置要进行分析的模型的根。
metric_engine = slmetric.Engine(); metric_engine.ModelReferencesSimulationMode = 'AllModes'; metric_engine.AnalyzeLibraries = 1; setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
收集模型度量数据
execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');
获取返回一个 slmetric.metric.ResultCollection 对象数组 res_col 的模型度量数据。
res_col = getMetrics(metric_engine, 'mathworks.metrics.ExplicitIOCount');
显示 mathworks.metrics.ExplicitIOCount 度量的结果。
for n=1:length(res_col)
if res_col(n).Status == 0
result = res_col(n).Results;
for m=1:length(result)
disp(['MetricID: ',result(m).MetricID]);
disp([' ComponentPath: ', result(m).ComponentPath]);
disp([' Value: ', num2str(result(m).Value)]);
disp([' AggregatedValue: ', num2str(result(m).AggregatedValue)]);
disp([' Measures: ', num2str(result(m).Measures)]);
disp([' AggregatedMeasures: ', num2str(result(m).AggregatedMeasures)]);
end
else
disp(['No results for:', result(n).MetricID]);
end
disp(' ');
end结果如下:
MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic Value: 3 AggregatedValue: 4 Measures: 0 3 AggregatedMeasures: 3 3 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic/More Info Value: 0 AggregatedValue: 0 Measures: 0 0 AggregatedMeasures: 0 0 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_counter Value: 4 AggregatedValue: 4 Measures: 3 1 AggregatedMeasures: 3 1
对于 ComponentPath: sldemo_mdlref_basic,值为 3,因为有 3 个输出。这三个输出位于 Measures 数组的第二个元素中。slmetric.metric.AggregationMode 是 Max,所以 AggregatedValue 是 4,也就是 sldemo_mdlref_counter 的输入和输出数。AggregatedMeasures 数组包含组件或子组件的最大输入和输出数。
版本历史记录
在 R2016a 中推出以后的版本中将会删除度量仪表板用户界面、metricdashboard 函数、slmetric 包 API 以及相应的自定义项。有关详细信息,请参阅Migrating from Metrics Dashboard to Model Maintainability Dashboard。
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)