Call parameters by their variable name in Simulink rather than having to index the value.

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?
For instance, I have a variable named "khch" and when conducting sensitivity analysis I would prefer to directly assess based off that variable name rather than having to call the value as "parameters(37)", given it is the 37th parameter in the array.
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)?
The parameters vector is filled by running a script prior to running the Simulink model. The assignment of variables to their associated values is done within a "MATLAB Function" within the Simulink space.
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.

Sign in to comment.

Answers (2)

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.
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
ans = 2

2 Comments

I have tried this and it still doesn't let you directly call the variable by name (e.g., "parameters.khch" or just "khch") when using "Parameter Estimator" or "Sensitivity Analyzer" in Simulink.
Sorry. As not a simulink user, I don't know how to pass in a struct.

Sign in to comment.

Categories

Products

Release

R2026a

Asked:

on 26 May 2026

Commented:

on 28 May 2026

Community Treasure Hunt

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

Start Hunting!