How can I find duplicate sub systems in model using m-script
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
gvreddy
el 7 de Mayo de 2015
Respondida: Nobel Mondal
el 13 de Mayo de 2015
Hello,
I want to find duplicate sub systems in model. For example, I have sub system like shown image.
As we can see, duplicate sub system2 is created even though there is no IO changes.
so my interest is to find these kind issues in model using MATLAB commands.
Here is my code as of now:
subSystemHandles = find_system(bdroot,'BlockType','SubSystem');
for k=1 : length(subSystemHandles)
allSubSystem = get_param(subSystemHandles(k),'Name');
eachSubSystem = get(gcbh);
inPortHandles = eachSubSystem.LineHandles.Inport;
inPortNames=get(inPortHandles,'Name');
outPortHandles = eachSubSystem.LineHandles.Outport;
outPortNames=get(outPortHandles,'Name');
end
Here I am trying to read Names of Inport and OutPort using get_param but I am not getting names.
Please, Could some one help me on this?
1 comentario
Nobel Mondal
el 13 de Mayo de 2015
Editada: Nobel Mondal
el 13 de Mayo de 2015
From what I understand, if a particular SubSystem block has the following blocks within - it would be flagged as redundant.
1. Matching ports and port-blocks within.
2. A single SubSystem block.
3. No other blocks.
Would you agree that this is the problem you're trying to solve?
Respuesta aceptada
Nobel Mondal
el 13 de Mayo de 2015
This below code should work for reasonably simple subsystems. I haven't tried for any complex ones - like with triggered input.
mdl = 'MySubSys';
load_system('MySubSys')
allBlks = find_system(mdl, 'Type', 'block', 'BlockType', 'SubSystem');
flags = zeros(1,length(allBlks));
for k=1:length(allBlks)
currentPorts = get_param(allBlks{k}, 'Ports');
insideBlks = find_system(allBlks{k}, 'SearchDepth', 1, 'Type', 'block');
insideBlkType = get_param(insideBlks, 'BlockType');
insideIPnum = length(find(strcmp(insideBlkType, 'Inport')));
insideOPnum = length(find(strcmp(insideBlkType, 'Outport')));
insideSSNum = length(find(strcmp(insideBlkType, 'SubSystem')));
insideRestNum = length(insideBlkType)- insideIPnum - insideOPnum - insideSSNum;
if insideIPnum==currentPorts(1) && insideOPnum==currentPorts(2) ...
&& insideSSNum==2 && insideRestNum==0
flags(k)=1;
end
end
ids = find(flags(:)==1);
redundantSubSys = allBlks(ids);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!