setting parameters for 4 Blocks (wrong number of input arguments, should be odd?)

11 views (last 30 days)
Hello,
when i set the Parameters for 1 Block i dont have any Problems( 3 input arguments )
But as soon as i want to do it for 4 i get an error message
set_param('model/Transfer Fcn','Denominator','T11','model/Transfer Fcn1','Denominator','T12','model/Transfer Fcn2','Denominator','T21','model/Transfer Fcn3','Denominator','T22');
Wrong number (12) of input arguments detected
At least 3 arguments are needed for set_param.
The number of arguments should be an odd value.
that doesnt make any sense to me , since there are 3 input arguments for every Block.
why do i get an error and how can i solve it ?
thanks in advance and
Kind regards,
Bünyamin

Accepted Answer

Rollin Baker
Rollin Baker on 13 Apr 2017
Hi Bünyamin,
The reason you are seeing this error is because the 'set_param' function is only meant to be called on a single block at a time. You will need to call it on each block individually. For example:
set_param('model/Transfer Fcn','Denominator','T11');
set_param('model/Transfer Fcn1','Denominator', 'T12');
set_param('model/Transfer Fcn2','Denominator','T21');
set_param('model/Transfer Fcn3','Denominator','T22');
This will give you the behavior you want without any errors. If you want to learn more about the 'set_param' function, check out the documentation page below:
I hope this helps. Good luck with your project!
-Rollin

More Answers (0)

Categories

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

Products

Community Treasure Hunt

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

Start Hunting!