2015-04-21 36 views
0

如何通过M-Script(分层)对状态流图中的状态数进行计数?计数StateFlow中的状态数

+0

您可能需要使用[Simulink Design Verifier](http://uk.mathworks.com/products/sldesignverifier/features.html#model-coverage-analysis)进行覆盖率分析。这将为您提供Stateflow图表可以进入的所有状态。 – am304

回答

0

你可以用Stateflow的API来做到这一点:

m = rt.find('-isa','Simulink.BlockDiagram','Name', modelName); 
%% find all the Charts in the model 
chartList = m.find('-isa','Stateflow.Chart'); 

%% find all of the states in level 1 of the first chart 
stateList = chartList(1).find('-isa', 'Stateflow.State', '-depth', 1); 
disp(length(stateList)); 

必须运行此脚本之前先打开模型。