필터 지우기
필터 지우기

How can I come to know whether a stateflow chart is open from command prompt?

조회 수: 2 (최근 30일)
Hi,
I have stateflow in my model.If stateflow is open,then while doing simulation , it takes lot of time since it animates it. So I want to make sure that whether the staeflow in my model is open or not & if it is open then I want to close it first then save the model(so that when I run sim command, it will run quickly with state chart closed), but if stateflow is not open then there is no need to save the model & I can run sim command directly.using sfclose is an option, but it do not tell me whether stateflow was open or not(so I cant decide whether to save model or not ), I want to confirm first that it is open & then only I want to use sfclose. I have tried hndls =find_system(<mdl>,'BlockType','SubSystem','Open','on'); but it gives empty array even though stateflow chart is open or closed.
Please suggest. Thanks is advance! Sameer

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 12월 19일
sfclose only closes the opened Stateflow window. It doesn't impact the "save" status of the model at all. So it's safe to run sfclose('all') before you run simulation to speed it up.
To find the Stateflow chart, you need to add the 'MaskType','Stateflow' pair. But it won't find the opened Stateflow it you combine it with the 'Open','On' pair. There might be a way, but I don't think it matters for your purpose.
For the sake of knowing how to do it.
rt = sfroot;
chart = rt.find('-isa','Stateflow.Chart');
set(chart,'visible',1);
set(chart,'visible',0);

추가 답변 (1개)

Kaustubha Govind
Kaustubha Govind 2011년 12월 19일
You can use the Stateflow API to do this:
myModel = 'sf_car';
open_system(myModel);
rt = sfroot;
m = rt.find('-isa', 'Simulink.BlockDiagram', '-and', 'Name', myModel);
ch = m.find('-isa','Stateflow.Chart');
anyOpen = false;
for i = 1:numel(ch)
if ~anyOpen && (ch.Visible==1)
anyOpen = true;
end
if (ch.Visible==1)
ch.Visible=0;
end
end
if anyOpen
save_system(myModel);
end

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by