How do I update Simulink model parameters during a simulation?
Mostra commenti meno recenti
I have a Discrete PI controller Simulink model embedded within a triggered sub-system. I have a separate piece of embedded Matlab code which I am trying to use to update the PI controller parameters, such as the Gain, upper and lower limits etc.
In the embedded Matlab code, I have the following line:
GainValue_s(:) = GainValue_s+5.25;
assignin('base','GainValue',GainValue_s);
so I'm assigning the gain value to a workspace variable, this is updated periodically throughout the simulation.
In the Simulink model PI controller, the field for the 'Proportional (P):' gain value has the following:
evalin('base','GainValue')
The design compiles and simulates without any errors, however I think that the triggered subsystem only uses the first GainValue that it picks up from the base workspace, I know that the GainValue changes during the simulation but the output from the PI controller remains constant after the first trigger.
Any ideas if what I'm doing is valid or not, or is there a better way of updating these values on the fly?
Thanks
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Simulink in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!