Collect and access model metric data for the model
sldemo_mdlref_basic
.
Create an slmetric.Engine
object. Include referenced
models and libraries in the analysis and set the root in the model for
analysis.
metric_engine = slmetric.Engine();
metric_engine.ModelReferencesSimulationMode = 'AllModes';
metric_engine.AnalyzeLibraries = 1;
setAnalysisRoot(metric_engine, 'Root', 'sldemo_mdlref_basic');
Collect model metric data
execute(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Get the model metric data that returns an array of slmetric.metric.ResultCollection
objects,
res_col
.
res_col = getMetrics(metric_engine, 'mathworks.metrics.ExplicitIOCount');
Display the results for the
mathworks.metrics.ExplicitIOCount
metric.
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
Here are the results:
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
For the ComponentPath: sldemo_mdlref_basic
, the value
is 3
because there are 3
outputs. The
three outputs are in the second element of the Measures
array. The slmetric.metric.AggregationMode
is
Max
, so the AggregatedValue
is
4
which is the number of inputs and outputs to
sldemo_mdlref_counter
. The
AggregratedMeasures
array contains the maximum number
of inputs and outputs for a component or subcomponent.