I need to add a disturbance factor 0.2 value after 500 sec ,when my system is stable in order to check the stability while using PID controller in MATLAB code . what to do ??

조회 수: 9 (최근 30일)
I have a closed loop transfer funtion with PID controller but i need to add a distrunabe value 0.2 after 500 sec in the output response to check disturbance rejection form the system. for that in MATLAB code what to do

답변 (1개)

Joel
Joel 2023년 3월 14일
Hi,
I understand that you want to write MATLAB code to be able to add a disturbance at some given time while simulating your system and observe system dynamics. This can easily be done on Simulink using the step and transfer function blocks.
To achieve this in MATLAB, you should use the ‘lsim’ function. An example code is as follows:
TF = tf([1 3],[1 5 3]); % some transfer function
h = 0.001; % sample time
T = 1000; % simulation time
t = 0:h:T; % time samples
T_dist = 500; % time at which disturbance is introduced
t1 = 0:h:T_dist-h;
t2 = T_dist:h:T;
% divide the input signal into two parts. initial input of 1 is given at 0s and
% disturbance of 0.2 is given at 500s.
u = [ones(1,length(t1)),0.2*ones(1,length(t2))];
lsim(TF,u,t);

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by