summaryrefslogtreecommitdiff
path: root/2048/CH7/EX7.4/lead_lag.sce
blob: 0a7fbb640a4e79e27cb14156b215b54a0d78e798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// A procedure to design lead controllers, as explained in Fig. 7.12 on page 257.
// 7.4

exec('tf.sci',-1)

w = linspace(0.001,%pi,1000);
a = linspace(0.001,0.999,100);
lena = length(a);
omega = []; lead = [];
for i = 1:lena,
    zero = a(i);
    pole = 0.9*zero;
    sys = tf([1 -zero],[1 -pole],-1);
    frq = w/(2*%pi);
    [frq,repf]=repfreq(sys, frq);            
    [db,phase] =dbphi(repf);
    [y,j] = max(phase);
    omega = [omega w(j)];
    lead = [lead y];
    comega = (pole+zero)/(pole*zero+1);
    clead = zero-pole;
    clead1 = sqrt((1-zero^2)*(1-pole^2));
    clead = clead/clead1;
//    [w(j) acos(comega) y atan(clead)*180/pi]
end
subplot(2,1,1), plot(lead,omega)
xtitle('','','Frequency, in radians'), xgrid;
halt;
subplot(2,1,2), plot(lead,a)
xtitle('','Lead generated, in degrees','Zero location'), xgrid;