'outdated' property of slmetric.m​etric.Resu​ltCollecti​on not showing true even though model is changed

3 views (last 30 days)
I want to execute the model metric programmatically only if there is change in the model. I am using 'outdated' property of slmetric.metric.ResultCollection to read the information.As per documentation ,outdated property of slmetric.metric.ResultCollection returns true if there is a model change. But its not happening.
I am follwing the below sequence of operation.
  • metric_engine = slmetric.Engine();
  • setAnalysisRoot(metric_engine,'Root',<model_name>,'RootType', 'Model');
  • execute(metric_engine)
2)did some modification in the model manullly(removed some blocks)
3)res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
my expectation is res_col.Outdated should return true as there are model changes after the metrics execution.But its returining false always
Please let me know how to execute the model metric programmatically only if there is change in the mode?

Answers (1)

Aneela
Aneela on 10 Oct 2024
Hi Abina Ansary,
You should call “execute” after any changes to a metric to ensure that the status of “outdated” property is updated for previously collected metrics.
Refer to the below example:
metric_engine = slmetric.Engine();
setAnalysisRoot(metric_engine,'Root','MySimpleModel','RootType', 'Model');
execute(metric_engine, 'mathworks.metrics.SimulinkBlockCount')
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
res_col.Outdated ;
% modify the model and save
execute(metric_engine, 'mathworks.metrics.FileCount');
%get block count results and see Outdated == true
res_col = getMetrics(metric_engine, 'mathworks.metrics.SimulinkBlockCount');
res_col.Outdated ;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!