이 예에서는 sldemo_mdlref_basic
모델에 대한 지표 데이터를 수집하고 액세스하는 방법을 보여줍니다.
sldemo_mdlref_basic
모델을 엽니다.
open_system('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, '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
ComponentPath: sldemo_mdlref_basic
의 경우 출력이 3개이므로 값은 3
입니다. 세 개의 출력은 Measures
배열의 두 번째 요소에 있습니다. slmetric.metric.AggregationMode
은 Max
이므로 AggregatedValue
은 4
이며, 이는 sldemo_mdlref_counter
에 대한 입출력 개수입니다. AggregatedMeasures
배열에는 구성 요소 또는 하위 구성 요소에 대한 최대 입력 및 출력 수가 포함됩니다.