⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 最少拍无纹波控制器设计.txt

📁 最少拍无纹波控制器的设计及matlab仿真
💻 TXT
字号:
M文件:
clear;            %清除工作空间中的变量
s=tf('s');
G=8/(0.6*s^2+s);
G1=c2d(G,0.7)           %包含零阶保持器的状态到离散传递函数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          %各传递函数
Qe=(1-z^-1)*(1+0.405*z^-1)
disp('controlor:');
D=Q/G1/Qe
disp('error:');
E=Qe*R
[num1,den1]=tfdata(Qe)          %转换成分子分母形式,为了使用dstep()函数
[y1,x1]=dstep(num1,den1)        % dstep()函数为单位阶跃响应函数
p=0:0.7:0.7*(length(y1)-1)        %图显示的横坐标范围

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是为了控制余数的项数
    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]    %因为输出的余数是从z^-2开始,所以要加两个零才能得出理论的曲线
    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 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -