blob: 528f672300e1d35c3ea771611ac2326095692257 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Example 10.2: Bode's plots
clc, clear
w=[0:0.1:8];
// Asymptotic magnitude response curve
for i=1:length(w)
a(i)=40;
if w(i)<1.3 then
b(i)=20*w(i);
c(i)=0;
d(i)=0;
e(i)=0;
elseif w(i)<3
b(i)=20*w(i);
c(i)=20*(w(i)-1.3);
d(i)=0;
e(i)=0;
elseif w(i)<6
b(i)=20*w(i);
c(i)=20*(w(i)-1.3);
d(i)=-20*(w(i)-3);
e(i)=0;
else
b(i)=20*w(i);
c(i)=20*(w(i)-1.3);
d(i)=-20*(w(i)-3);
e(i)=-20*(w(i)-6);
end
end
A=a+b+c+d+e;
plot2d(w,A,rect=[0,0,7,200]);
xtitle("Amplitude (Gain) |A(jω)| in dB","log ω","|A(jω)| dB");
// Asymptotic phase response curve
scf(1);
for i=1:length(w)
thetab=90;
if w(i)<0.3 then
thetac(i)=0;
thetad(i)=0;
thetae(i)=0;
elseif w(i)<2
thetac(i)=45*(w(i)-0.3);
thetad(i)=0;
thetae(i)=0;
elseif w(i)<2.3
thetac(i)=45*(w(i)-0.3);
thetad(i)=-45*(w(i)-2);
thetae(i)=0;
elseif w(i)<4
thetac(i)=90;
thetad(i)=-45*(w(i)-2);
thetae(i)=0;
elseif w(i)<5
thetac(i)=90;
thetad(i)=-90;
thetae(i)=0;
elseif w(i)<7
thetac(i)=90;
thetad(i)=-90;
thetae(i)=-45*(w(i)-5);
else
thetac(i)=90;
thetad(i)=-90;
thetae(i)=-90;
end
end
theta=thetab+thetac+thetad+thetae;
plot(w,theta);
xtitle("Phase Φ(ω) in degrees","log10 ω","Φ(ω)")
|