How to Programmatically replace blocks in Simulink
83 views (last 30 days)
Show older comments
Ramae Smith on 26 Jul 2021
Commented: Ramae Smith on 2 Aug 2021
I have a model with hundreds of blocks from an old library that I want to replace.
I've made a dummy model. "Version 2" inside the model is the goal. I've done 3 by hand just for clarity.
I want to Replace all Step blocks with Constant blocks. I also want to take the Label of the Step block, and it to the Constant Value of the new Constant block.
There's a couple functions that could work that I've added to the script.
Let me know if you have ideas!
Shadaab Siddiqie on 29 Jul 2021
Form my understanding you want to replace few blocks in your model with another blocks. You can do this using replace_block like so:
%Load the model sldemo_clutch.
%In the 'Unlocked' subsystem, replace blocks whose Gain value is bv with Integrator blocks.
If you want to replace block in model with block from another model you can refer pil_block_replace.
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!