How to dynamically change Simulink variables from MATLAB App Designer after simulation is initiated
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daniel Williams
am 20 Jun. 2023
Kommentiert: Jon
am 21 Jun. 2023
I have designed an app using the MATLAB App Designer that has a slider. I would like to assign the value of the slider in the app to a variable in my Simulink model. I have tried using
assignin('base', 'variableName', sliderValue);
in the function SliderValueChanged(), however while I can see that the value of variableName changes in the MATLAB workspace, it does not change in the Simulink model: a constant block set equal to variableName remains at the value of variableName at t=0 s is used for all time). Is there a way to have the Simulink model update variableName after model execution has begun?
0 Kommentare
Akzeptierte Antwort
Jon
am 20 Jun. 2023
You should be able to use set_param, for this purpose.
So for example:
set_param('mymodel/Gain','Gain',num2str(11))
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!