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

4 次查看(过去 30 天)
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?

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-12-9
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

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by