'Use matlab script to check symbol types in state chart
I am writing a script that will open a simulink model and check for all the logical comparison data types. I have four comparisons in my model, two of which are logical operators, the other two are condition statements in the state chart shown below.

Using a script I can check the data types of the logical operators shown below but I'm having trouble finding documentation on how to check the symbol data types from the state chart.
load_system('comparison.slx');
RelOps = find_system('comparison','BlockType','RelationalOperator');
for j = 1:numel(RelOps)
currRelOp = get_param(RelOps(j),'Operator');
if strcmp(currRelOp,'==')
currpc = get_param(RelOps(j),'PortConnectivity');
currpc = currpc{1,1};
srcblktype = get_param(currpc(2).SrcBlock,'BlockType');
if strcmp(srcblktype,'Constant')
srcblkdatatype = get_param(currpc(2).SrcBlock,'OutDataTypeStr');
end
end
I thought I would post this up on stack overflow while continuing my search. So far I have a script which can find all the variable names
compList = {'==' '!=' '<' '>' '<=' '>='};
charts = find(sfroot,'-isa','Stateflow.Chart');
st = find(charts(1),'-isa','Stateflow.Transition');
inputList = {};
for i = 1:numel(st)
condStr = st(i).LabelString;
if ~strcmp(condStr,'')
if contains(condStr, compList)
splitStr = split(condStr,compList);
for j = 1:numel(splitStr)
inputStr = char(splitStr(j));
inputStr = erase(inputStr,{' ','[',']'});
inputList = [inputList {inputStr}];
end
end
end
% For loop searching for data types
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
