|
<>程序之二</P>
<>控制工程基础中在画根轨迹时候求分离点以及渐进线的程序:
分离点的:
function [K,S]=flds(G)
G=tf(G);
num=G.num{1};
den=G.den{1};
dt=get(G,'inputdelay');
syms ns ds
a=conv(den,polyder(num));
b=conv(num,polyder(den));
a1=([zeros(1,length(b)-length(a)),a]-b);
a2=dt*conv(num,den);
ss=roots([zeros(1,length(a2)-length(a1)),a1]-a2);
k=[];
s=[];
for i=1:length(ss)
ns=poly2sym(num,'s');
ds=poly2sym(den,'s');
Kk(i)=-subs(ns/ds,'s',ss(i));
if Kk(i)>0
k=[k,Kk(i)];
s=[s,ss(i)]
disp (s)
else
S='此系统无分离点!';
end
end</P>
<>
渐进线:
function s=jjx(G)
G=tf(G);
num=G.num{1};
den=G.den{1};
dt=get(G,'inputdelay');
p=roots(den);
z=roots(num);
n=length(p);
m=length(z);
if dt==0
if n>m
s=(sum(p)-sum(z))/(n-m);
sd=[];
if nargout <1
for i=1:n-m
sd=[sd,s];
end
Ga=zpk([],sd,1);
hold on;
[r,k]=rlocus(Ga);
for i=1:n-m
plot(real(r(i,),imag(r(i,),'r:');
end
end
else
disp('没有渐进线')
s=[];
end
else
a=get(gca,'xlim');
b=pi/dt;
line(a,[b b],'linesty','r:');
line(a,[-b -b],'linesty','r:');
end
</P> |
|