How can I create a script to automatically delete unconnected lines from my Simulink model in Simulink 7.6 (R2010bSP1)?
20 views (last 30 days)
Show older comments
I would like to write a script to delete unconnected lines within the model.
Accepted Answer
MathWorks Support Team
on 9 Aug 2012
If you would like to see which blocks are unconnected, get a handle to the ports of the block you would like to check, then use delete_line to remove unconnected lines. The example below will try to delete the unconnected Outport blocks within a loop.
open_system('test')
blks = find_system(bdroot, 'Type', 'block');
listblks = get_param(blks, 'BlockType') ;
for i = 1:length(listblks)
if strcmp(listblks(i),'Outport')
lines = get_param(blks(i),'PortConnectivity');
if lines{1,1}.SrcBlock == -1
disp(blks(i))
h = get_param(blks(i),'LineHandles');
delete_line(h{1,1}.Inport);
delete_block(blks(i));
end
end
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!