MATLAB: Avoid searching the commented out logic seach in Stateflow API.

stateflowstateflow api

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 ??

Best Answer

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!