Clear Filters
Clear Filters

How to add multiple "display" block to multiple subsystems in a simulink file programmatically

4 views (last 30 days)
Problem statement: I have 500 of subsystem in a simulation file. I need to add display block in simulink to all subsystems. Manually doing it is taking lot of time. Is there is any method is there to script it automatically?
I have tried with following code, it is working correctly with one subssytem
"add_block('simulink/Sinks/Display','simulation path of one subsystem')
add_line('simulation path of one subsystem','Display/1','autorouting','on')
But if I use same code for all subsystems means once again declaring path of all subsystems is time consuming. Is there is any other ways is there?

Answers (1)

Fangjun Jiang
Fangjun Jiang on 9 Dec 2023
Yes you can do it programmingly. see help for find_system() and do something like this:
AllSys=find_system(ModelName, 'SearchDepth',1,'BlockType','Subsystem')
for k=1:numel(AllSys)
add_block(...)
end

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!