?? 最少拍無紋波控制器設(shè)計(jì).txt
字號:
M文件:
clear; %清除工作空間中的變量
s=tf('s');
G=8/(0.6*s^2+s);
G1=c2d(G,0.7) %包含零階保持器的狀態(tài)到離散傳遞函數(shù)Z變換
f=input('select intput form:1.stepinput 2.rampintput');%選擇輸入形式
z=tf('z');
if f==1 %單位階躍輸入
disp('input:');
R=z/(z-1)
Q=(z+0.6804)*0.595/z^2 %各傳遞函數(shù)
Qe=(1-z^-1)*(1+0.405*z^-1)
disp('controlor:');
D=Q/G1/Qe
disp('error:');
E=Qe*R
[num1,den1]=tfdata(Qe) %轉(zhuǎn)換成分子分母形式,為了使用dstep()函數(shù)
[y1,x1]=dstep(num1,den1) % dstep()函數(shù)為單位階躍響應(yīng)函數(shù)
p=0:0.7:0.7*(length(y1)-1) %圖顯示的橫坐標(biāo)范圍
disp('output of controlor:');
U=E*R
[num2,den2]=tfdata(E)
[y2,x2]=dstep(num2,den2)
q=0:0.7:0.7*(length(y2)-1)
disp('output:');
Y=R*Q
[num3,den3]=tfdata(Q)
[y3,x3]=dstep(num3,den3)
v=0:0.7:0.7*(length(y3)-1)
subplot(2,2,1),stem(p,y1,'r');holdon;stairs(p,y1,'b');gridon;xlabel('Time/s');ylabel('Amplitude');
title('Discrete step response of error');axis([0,10,0,1.5]);hold off
subplot(2,2,2),stem(q,y2,'r');hold on;stairs(q,y2,'b');grid;xlabel('Time/s');ylabel('Amplitude');
title('Discrete step response of controlor');axis([0,10,0,1.5]);hold off
subplot('position',[0.2,0.05,0.6,0.45]),stem(v,y3,'r');hold on;stairs(v,y3,'b');grid;xlabel('Time/s');
ylabel('Amplitude');title('Discrete step response of output');axis([0,10,0,1.5]);hold off
else if f==2 %單位速度輸入
disp('input:')
R=0.7*z/(z-1)^2;
g=[0.7 0];
h=[1 -2 1];
Q=(1+0.6804*z^-1)*(1.431*z^-1-0.836*z^-2);
Qe=(1-z^-1)^2*(1+0.569*z^-1);
disp('controlor:');
D=(1-0.3114*z^-1)*(1.431*z^-1-0.836*z^-2)/2.2947/z^-1/(1-z^-1)/(1+0.569*z^-1)
disp('output of control:');
U=0.7*(1-0.3114*z^-1)*(1.431*z^-1-0.836*z^-2)/2.2947/(1-z^-1)
c=[0.4365 -0.391 0.07941 0 0];
d=[1 -1 0 0 0 0];
disp('output:');
Y=0.7*z^-1*(1+0.6804*z^-1)*(1.431*z^-1-0.836*z^-2)/(1-z^-1)^2
e=[1.002 0.09636 -0.3982 0 0 0];
f=[1 -2 1 0 0 0 0 0];
disp('error:');
E=0.7*z^-1*(1+0.569*z^-1)
a=[0.7 0.3983]
b=[1 0 0]
x1=deconv([a,zeros(1,10)],b) %使用長除法,zeros是為了控制余數(shù)的項(xiàng)數(shù)
x=[0 x1]
p=0:0.7:(length(x)-1)*0.7
y1=deconv([c,zeros(1,15)],d)
y=[0 y1]
l=0:0.7:(length(y)-1)*0.7
z1=deconv([e,zeros(1,10)],f)
z=[0 0 z1] %因?yàn)檩敵龅挠鄶?shù)是從z^-2開始,所以要加兩個(gè)零才能得出理論的曲線
r1=deconv([g,zeros(1,10)],h)
r=[0 r1]
n=0:0.7:7
m=0:0.7:(length(z)-1)*0.7
subplot(2,2,1),stem(p,x,'g');hold on; stairs(p,x,'r');grid;xlabel('Time/s');ylabel('Amplitude');
title('Discrete step response of error');hold off
subplot(2,2,2),stem(l,y,'g');hold on;stairs(l,y,'r');grid;xlabel('Time/s');ylabel('Amplitude');
title('Discrete step response of controlor');hold off
subplot('position',[0.2,0.05,0.6,0.45]),stem(m,z,'g');hold on;stairs(m,z,'r');plot(m,z,'m');plot(n,r);
grid;xlabel('Time/s');ylabel('Amplitude');title('Discrete step response of output');hold off
end
end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -