Clear Filters
Clear Filters

parameter tuning in matlab simulink

1 view (last 30 days)
Maya
Maya on 7 Mar 2024
Answered: Gyan Vaibhav on 13 Mar 2024
How can enable Tuning of different parameters in Simulink
  2 Comments
Rohit Kulkarni
Rohit Kulkarni on 7 Mar 2024
Hi Maya.
In my understanding you want to tune parameters of your Simulink model to evaluate your model and check edge cases.
To enable this you can change the block parameters via the block parameter dialog box, Dashboard blocks and MATLAB language. You can also create tunable global parameters by using MATLAB variables as value expressions.
Refer to the following documentation for examples:
Thanks
Maya
Maya on 7 Mar 2024
Hello Rohit,
Thank you for your ans. But I want to know how can I tune the variable in simulink model only in 2017 a version. I tried with scripting but that's not in my requirement.
ex. addition of 2 input port. if I want to tune input ports as runtime how can I do that.
Can you share solution with model please?

Sign in to comment.

Answers (1)

Gyan Vaibhav
Gyan Vaibhav on 13 Mar 2024
Hi Maya,
For tuning parameters you need to determine and make sure a few things, such as is your parameter tunable, if yes your simulation must take enough time to simulate for you to change the values of your tunable parameters.
I have made a very simplistic model of summation of a sine wave with a constant block, similar to the example you requested.
  1. You can use workspace variables or Simulink Parameters objects to set block parameter values to be tuned.To access the value of a block parameter, such as the Constant value parameter of a Constant block, you must navigate to the block in the model and open the block dialog box, search for the block by using the Model Explorer, or use the function set_param at the command prompt.
  2. To observe simulation output in real time while you tune block parameter values, you can use blocks in a model such as the Scope block.
  3. A simulation run can execute so quickly that you cannot tune block parameter values. Also, if you want to change a parameter value at a specific simulation time, you must learn to control the simulation pace. You can configure the simulation to run for a specific duration or to run forever, and pause and advance the simulation when you want to. Or you can stop it at a certain time and then go on stepping. (You can stop simulation by configuring in the scope options).
  4. If you set the block parameter value by creating a workspace variable, you can change the value of the variable by using the command prompt, the MATLAB Workspace browser, or the Model Explorer. You can also create a variable to set the same value for multiple block parameters. When you change the variable value, all of the target block parameters use the new value.
  5. In R2017a, you need to click Update Diagram (Simulation > Update Diagram) after every change in the variable to take effect. (Refresh Blocks works too but is greyed out when the simulation is paused).
Below is a sample screenshot from the output of the model, when I tuned it in real time.
I highly recommend you to go through this documentation to learn how parameters can be tuned in detail: https://www.mathworks.com/help/simulink/ug/using-tunable-parameters.html
Hope this helps.
Thanks
Gyan

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!