Changing gain parameter in matlab function block during simulink simulation

Hi, I need to change gain/constant parameter in Simulink during the simulation. Sometimes it need to be changed and sometimes it doesn't, so I try to do it in the Matlab function block. Anyway, I didn't find a solution without a GUI... I already tried set_param function but it doesn't work in matlab function block.
My real issue is to set PD controller until the condition isn't true. Than I need only PID controller no matter the condition.
Thanks for help in advance
function [PD, PID] = PID_switch(PID_set, error)
if PID_set == 0
PD = error;
PID = 0;
else
PID = error;
PD = 0;
end
if condition == 1
PID_set = 1;
end
end

Risposte (1)

Hi Jan,
As per my understanding, it appears that you are interested in employing the "PD" control block until a specific condition remains unfulfilled. Once this condition is met, the system should transition to the "PID" control block.
To facilitate this, I suggest utilizing the "Switch" block in Simulink. This block enables you to route one of its inputs to its output based on a specified "Threshold" parameter.
For a comprehensive understanding and examples, you may refer to the following documentation:
Best,
Umang

Categorie

Scopri di più su General Applications in Centro assistenza e File Exchange

Prodotti

Release

R2021b

Richiesto:

il 7 Mag 2022

Risposto:

il 25 Set 2023

Community Treasure Hunt

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

Start Hunting!

Translated by