- Tunable Block Parameters and Tunable Global Parameters - MATLAB & Simulink
- Tune Parameters by Using Simulink® External Mode - MATLAB & Simulink
manipulating blocks while real-time simulation running
9 views (last 30 days)
Show older comments
I am currently running real-time simulations in MATLAB Simulink, and I would like to modify certain parameters while the model is running. For example, I would like to manipulate the values of some Constant blocks during execution.
When I configure these parameters as tunable in the model settings, the displayed value of the block changes as expected. However, the signal output from the block continues to hold its previous data, without reflecting the new value. Additionally, when I attempt to apply changes directly from the MATLAB workspace, the modifications are not accepted.
0 Comments
Answers (1)
Spoorthy Kannur
on 17 Oct 2025 at 6:52
Hi Hilal,
You can follow these steps and see if it works out for you:
1. Simulink inlines during compilation if your constant is hardcoded: try changing it to a variable stored in the workspace.
2. Under Model Settings> Code Generation> Optimisation> Default Parameter behaviour: set to Tunable and make sure ‘Inline parameters’ is NOT selected.
3. One way you can change the value while running in Normal Mode:
myConst = 5; %variable in the constant block is assigned from workspace.
set_param(bdroot,'SimulationCommand','update'); %followed by ‘set_param’
‘set_param’ essentially forces Simulink to re-evaluate block parameter at run time.
4. You can also replace constant value with ‘Simulink.Parameter’ object configured for runtime tuning.
say, you set the Constant block value = myParam, then:
myParam = Simulink.Parameter;
myParam.Value = 5;
myParam.CoderInfo.StorageClass = 'ExportedGlobal'; % or 'ImportedExtern'
This forces the parameter to be stored in memory, not inlined, and it will update when you change it while the model runs.
5. Make sure your execution mode is set either to Normal or External (for real-time Simulation). Avoid using accelerator, rapid accelerator modes.
6. Do refer to these resources:
If this does resolve the issue, kindly reach out to MathWorks Technical Support for more help (Contact Support - MATLAB & Simulink.)
0 Comments
See Also
Categories
Find more on Target Computer Setup 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!