set_param() - programmatically change param of multiple blocks of the same type (for-loop)

6 views (last 30 days)
Hi everyone!
Suppose there are 50 blocks of the same type in a simulink/simscape model - let's say it is a pipe-block in simscape domain.
Is there any recipe to change a specific parameter of all blocks programmatically?
I have a solution, but it assumes that the bocks of the same type are named with a consecutive number like this: pipe_1, pipe_2.
for iter_pipes = 1:50
model_name + "/pipe_" + string(iter_pipes),...
Is there any way to access a specific param of multiple blocks of the same type regardless of the blocks name?
Thank you in advance for any help!

Accepted Answer

Jesús Zambrano
Jesús Zambrano on 10 Aug 2021
That´s a good solution. For any other case, you might try to first use the command find_system, to then look for the blocks you want to change.
The following link has some examples of how to use this command:

Sign in to comment.

More Answers (0)


Find more on Creating Custom Components and Libraries 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!