matlab 中带迟延环节的开环传递函数来获得其闭环传递函数

来源:互联网 发布:sql例题 编辑:程序博客网 时间:2024/06/11 21:03

采用PADE函数,有理函数来近似

 

%PID   带滞后的传递函数,not use feedback,but pade
%将迟延环节表示成一个多项式,有理函数来近似
% 传递函数为G(s)=2*e^(-0.5s)/(2s+1),
clc
clear all
close all
num=[0 2];
den=[2 1];
delay=0.5;
%T为延迟时间常数,n为要求拟合的阶数
[n2,d2]=pade(delay,2)
num2=conv(num,n2);
den2=conv(den,d2);
disp('object tranfer function')
G_obj=tf(num2,den2)%object transfer function
Kp=2;Ti=2;Td=0;%由对象模型求出理想PID
%PID tranfer function
disp('PID tranfer function')
G_PID=tf(Kp*[Ti*Td,Ti,1]/Ti,[1,0])
%Close tranfer function
G=feedback(G_PID*G_obj,1);
figure;
grid on;
hold on
step(G,'g')
xlabel('t');
ylabel('y');
%axis([0,12,0,1.3]);
grid on;
%error
hold off;
[y,t]=step(G);
error=1-y;
figure
plot(t,error)
xlabel('t');
ylabel('error');
grid on