MATLAB Answers

How to modify or tune Simscape Tunable Parameters at simulation run-time?

7 views (last 30 days)
I am generating code and compiling an executable from my Simscape model, with the intent to change tunable parameters at run-time. 
In the generated code, tunable parameters added to my model are not showing up as expected in the code using the 'grt' target. Likewise, my generated executable does not respond to my attempts to change the tunable parameter's value at run-time. Why might this be?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 May 2021
Edited: MathWorks Support Team on 30 Jun 2021
In Simscape the process to make parameters run-time tunable is a bit different from base Simulink.
By default, Simscape will compute parameter values at compile-time and not at run-time. This preference option can be changed from MATLAB Preferences.
1. Open the MATLAB Preferences Dialog.
2. Select Simscape from the left pane.
3. Select the "Show run-time parameter settings" option.
Now, tunable parameters in your Simscape blocks will have a dropdown next to their values to select either "run-time" or "compile-time". For tunability in Fast Restart or Rapid Acclerator, set the option to "run-time".
Refer to the following documentation pages for more information about Simscape Run-Time Parameters:

More Answers (0)




Community Treasure Hunt

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

Start Hunting!