Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Ziegler-nichols

ng=[1 -1];
dg=[1 3.1 3.57 1.813 0.343];
G=tf(ng,dg);
clf,rlocus(G);
[km,pole]=rlocfind(G)
wm=max(imag(pole));
kp=0.6*km;
kd=(kp*pi)/(4*wm);
ki=(kp*wm)/pi;
nk=[kd kp ki];
dk=[1 0];
gc=tf(nk,dk)
gd=series(G,gc)
GT=feedback(gd,1)
step(GT,'r')
hold on
GS=feedback(G,1)
step(GS,'g')
----------------------Routh
13
clc
14
clear
15
r=input('input vector of your system coefficents: ');
16
m=length(r);
17
n=round(m/2);
18
q=1;
19
k=0;
20
for p = 1:length(r)
21
if rem(p,2)==0
22
c_even(k)=r(p);
23
else
24
c_odd(q)=r(p);
25
26
k=k+1;
27
q=q+1;
28

end
29
end
30
a=zeros(m,n);
31
32
if m/2 ~= round(m/2)
33
c_even(n)=0;
34
end
35
a(1,:)=c_odd;
36
a(2,:)=c_even;
37
if a(2,1)==0
38
a(2,1)=0.01;
39
end
40
for i=3:m
41
for j=1:n-1
42
x=a(i-1,1);
43
if x==0
44
x=0.01;
45
end
46
47
a(i,j)=((a(i-1,1)*a(i-2,j+1))-(a(i-2,1)*a(i-1,j+1)))/x;
48
49
end
50
if a(i,:)==0
51
order=(m-i+1);
52
c=0;
53
d=1;
54
for j=1:n-1
55
a(i,j)=(order-c)*(a(i-1,d));
56
d=d+1;
57
c=c+2;
58

end
59
end
60
if a(i,1)==0
61
a(i,1)=0.01;
62
end
63
end
64
Right_poles=0;
65
for i=1:m-1
66
if sign(a(i,1))*sign(a(i+1,1))==-1
67
Right_poles=Right_poles+1;
68
end
69
end
70
fprintf('\n Routh-Hurwitz Table:\n')
71
a
72
fprintf('\n Number Of Right Poles =%2.0f\n',Right_poles)
73
74
reply = input('Do You Need Roots of System? Y/N ', 's');
75
if reply=='y'||reply=='Y'
76
ROOTS=roots(r);
77
fprintf('\n Given Polynomials Coefficents Roots :\n')
78
ROOTS
79
else
80
end

You might also like