Call parameters by their variable name in Simulink rather than having to index the value.
Show older comments
I have a model I am running in Simulink that I now want to conduct sensitivty analysis on and am struggling how to assess based on parameter names rather than having to index for every individual parameter.
5 Comments
Can we be a little more specific about what "index for every individual parameter" means in this context? Particularly how indexing comes into play.
Are we talking about block parameters, like the 'Gain" parameter of the Gain - Multiply input by constant - Simulink block?
Matthew
on 26 May 2026
Paul
on 27 May 2026
Is the variable "khch" currently used in the Simulink model? Or does the Simulink model use the parameters vector to fill in various block parameters? If so, how does the parameters vector get filled before running the Simulink model, e.g., how does the value of khch get assigned into parameters(37)?
Matthew
on 27 May 2026
Paul
on 27 May 2026
The parameters vector is filled by running a script prior to running the Simulink model.
Now we have a Matlab Function block in the Simulink model. In that Matlab Function block is there a line like
khch = parameters(37)
and then khch is an output of the Matlab Function block? If so, how does the parameters vector get into the Matlab Function block?
Keep in mind that we have no idea what your Simulink model does, or how its structured, or how it's used. Without that information, it's hard to provide any advice/insight. Maybe a screenshot of the relevant part of the model would be helpful? Or a code snippet from this Matlab Function block. The more detail that you provide, the more likely it will be that you get useful help.
Answers (2)
Musa
on 26 May 2026
0 votes
ok so if you want lets say for an example to make khch = 2 and this value in the parameters(37), it is located at parameters(37), try on the matlab command window to make khch = parameter(37) this means khch now representing the parameters(37) which is 2.
John D'Errico
on 27 May 2026
Edited: John D'Errico
on 27 May 2026
If you can pass in a vector, then you can pass in a structure. Just assign fields to the structure.
parameters.khch = 2;
There is no need to access a numbered field. Now all you need do is acces it via
parameters.khch
2 Comments
Matthew
on 27 May 2026
John D'Errico
on 28 May 2026
Sorry. As not a simulink user, I don't know how to pass in a struct.
Categories
Find more on Simulink Functions 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!