Avoid searching the commented out logic seach in Stateflow API.

2 ビュー (過去 30 日間)
Arjunkrishna Mitta
Arjunkrishna Mitta 2020 年 12 月 11 日
コメント済み: Uday Pradhan 2020 年 12 月 14 日
I'm using a script to find all the parameters used in Stateflow logic of the model.
rt = sfroot;
m= rt.find('-isa','Stateflow.Chart'); % If not used in Simulink , Check in stateflow
params_sf = m.find('-isa', 'Stateflow.Data','Name',c_name);
*c_name - has the parameter name
But the only issue in this finds the parameters which are involved also in commented out statecharts.
How can i avoid searching in Commented out statecharts ??

採用された回答

Uday Pradhan
Uday Pradhan 2020 年 12 月 14 日
Hi Arjun,
According to my understanding, you want ignore the charts that are commented in the Stateflow logic of your model. To do this, you can create a custom filtering function to be used along with "find". Example:
f = @(h) (strcmp(get_param(h.path,'Commented'),'off')); %for the chart, return true if it is not commented
m = rt.find('-isa','Stateflow.Chart','-and','-function',f); %only returns those charts which are uncommented
I hope this helps!
  7 件のコメント
Arjunkrishna Mitta
Arjunkrishna Mitta 2020 年 12 月 14 日
I'm unable to find documentation as well for the custom filter you mentioned. even the link to documentation helps
Uday Pradhan
Uday Pradhan 2020 年 12 月 14 日
get_param(blockName,'Commented') returns 'on' or 'off' according to if the block is commneted or not. So I used this property to check if a chart if commented or not. In its present form:
f = @(rt)(strcmp(get_param(rt,'Commented'),'off'));%for the chart, return true if it is not commented
m = rt.find('-isa','Stateflow.Chart','-and','-function',f);
Should give charts that are NOT commented. I assume that is what you originally asked for. Here are the documentation pages I followed: find (check example section) and get_param.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by