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 ??
7 次查看(过去 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
0 个评论
回答(1 个)
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);
Please refer to the following documentation for more information: Plot simulated time response of dynamic system to arbitrary inputs; simulated response data - MATLAB lsim - MathWorks India
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 PID Controller Tuning 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!