I made a custome Library block which is basically a masked subsystem. I've put the masked subsystem inside another subytem and in its initialization section i made a code that replicates and connect copies of the custome block according to the wished number.
----------> In order to achieve this, all the blocks need to be deleted along with the lines connecting each block. To delete the lines i inserted the folowing code which works fine:
lines = find_system(gcb,'SearchDepth','1','LookUnderMasks','On','FindAll','On','Type','Line');
Now for the customed blocks i can't do the same since it doesnt get recognized. Following code has been tried:
blks = find_system(sys,'SearchDepth','1','LookUnderMasks','On','FindAll','On', 'BlockType', 'SubSystem');
Using Simulink.SubSystem.deleteContents(gcb) i was able to delete everything. However this deletes the ports as well which is something that i dont want to have since any conection with the main subsystem will be terminated. Any idea..?