主要内容

slmetric。引擎class

包:slmetric
超类:

收集模型或模型组件上的度量数据

描述

使用一个slmetric。引擎对象来收集模型上的度量数据执行.使用getMetrics访问度量数据并返回数组slmetric.metric.ResultCollection对象。此度量数据将持久保存在模拟缓存文件夹中。的未来实例化slmetric。引擎对象可以访问缓存的度量数据,而无需重新生成度量数据。

建设

metric_engine = slmetric.Engine ()创建一个度量引擎对象。

属性

全部展开

用于收集度量数据的根模型或子系统的名称,由slmetric.Engine.setAnalysisRoot方法。此属性是只读的。

指定度量引擎是否分析根模型中的库链接子系统,包括根下引用模型中的库。度量分析不包括链接到Simulink内置库的块。金宝app将该参数设置为0在度量分析中不包括库。

数据类型:逻辑

指定度量引擎是否分析根模型中的引用模型。从这些值中选择:

价值 描述
没有一个 度量引擎不为引用的模型收集度量数据。
NormalModeOnly 公制引擎只收集公制数据为参考模型运行在正常的模拟模式。
AllModes 公制发动机收集公制数据为参考模型运行在正常和加速模拟模式。

数据类型:字符

方法

执行 收集度量数据
exportMetrics 出口模式指标
getAnalysisRootMetric 仅为分析根获取一个度量的度量数据
getErrorLog 得到错误日志
getMetricDistribution 得到度量分布
getMetricMetaInformation 获取指标元数据
getMetrics 存取模型度量数据
getStatistics 获取度量数据的统计信息
setAnalysisRoot 为度量分析指定模型或子系统

例子

全部折叠

为模型收集和访问模型度量数据sldemo_mdlref_basic

创建一个slmetric。引擎对象,并在模型中设置根以便进行分析。

metric_engine = slmetric.Engine ();%在分析中包含引用的模型和库,%这些属性在默认情况下是打开的metric_engine。ModelReferencesSimulationMode =“AllModes”;metric_engine。AnalyzeLibraries = 1;setAnalysisRoot (metric_engine“根”“sldemo_mdlref_basic”);

收集模型度量数据

执行(metric_engine“mathworks.metrics.ExplicitIOCount”);

获取返回数组的模型度量数据slmetric.metric.ResultCollection对象,res_col

res_col = getMetrics (metric_engine,“mathworks.metrics.ExplicitIOCount”);

的结果显示mathworks.metrics.ExplicitIOCount指标。

n = 1:长度(res_col)如果res_col (n)。Status == 0 result = res_col(n).Results;m = 1:长度(结果)disp ([“MetricID:”,结果(m) .MetricID]);disp ([“ComponentPath:”,结果(m) .ComponentPath]);disp ([的价值:num2str(结果(m) value)]);disp ([“AggregatedValue:”num2str(结果(m) .AggregatedValue)]);disp ([的措施:num2str(结果(m)各行业)]);disp ([“AggregatedMeasures:”num2str(结果(m) .AggregatedMeasures)]);结束其他的disp ([“没有结果:”,结果(n) .MetricID]);结束disp (' ');结束

结果如下:

MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic值:3 AggregatedValue: 4措施:0 3 AggregatedMeasures: 3 3 MetricID: mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_basic /更多信息值:0 AggregatedValue: 0措施:0 0 AggregatedMeasures: 0 0 MetricID:mathworks.metrics.ExplicitIOCount ComponentPath: sldemo_mdlref_counter值:4 aggregatevalue: 4 Measures: 3 1 aggregatemeasures: 3 1

ComponentPath: sldemo_mdlref_basic,其值为3.因为有3.输出。的第二个元素中有三个输出措施数组中。的slmetric.metric.AggregationMode马克斯,所以AggregatedValue4输入和输出的数量是多少sldemo_mdlref_counter.的AggregratedMeasures数组包含组件或子组件的最大输入和输出数量。

介绍了R2016a