Changing gain parameter in matlab function block during simulink simulation

조회 수: 7 (최근 30일)
Jan Brieznik
Jan Brieznik 2022년 5월 7일
답변: Umang Pandey 2023년 9월 25일
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

답변 (1개)

Umang Pandey
Umang Pandey 2023년 9월 25일
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

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by