summaryrefslogtreecommitdiff
path: root/40/CH9/EX9.1/Exa_9_1.sce
blob: 44b5d2b9dec1b7066b979f43fcc226bd0967d402 (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
//Response in variant mappings
s=%s;z=%z;
HS=1/(s+1);
f=0:0.05:0.5;
HS1=horner(HS,(%i*%pi*2*f'));
ts=1;
HZ=z/(z-0.3679);
HZ1=horner(HZ,exp(%i*%pi*2*f'));
a=gca();
a.x_location="origin";
subplot(211)
plot2d(f,HS1);
plot2d(f,HZ1);
xlabel('Analog frequency f(Hz)');
ylabel('Magnitude');
xtitle('magnitude of H(s) and H(z)');
HZ1=HZ1-0.582;//magnitude after gain matching at dc 
b=gca();
b.x_location="origin";
subplot(212);
plot2d(f,HS1);
plot2d(f,HZ1);
xlabel('Analog frequency f(Hz)');
ylabel('Magnitude');
xtitle('magnitude after gain matching at DC');
//Impulse response of analog and digital filter
t=0:0.01:6;
ht=exp(-t');
n=0:6;
hn=exp(-n');
xset('window',1)
c=gca();
subplot(211);
plot2d(t,ht);
plot2d3('gnn',n,hn);
xlabel('DT index n and time t=nts');
ylabel('Amplitude');
xtitle('Impulse response of analog and digital filter');
//Step response of analog and digital filter
t=0:0.01:6;
st=1-exp(-t');
n=0:6;
sn=(%e-%e^(-n'))/(%e-1);
c=gca();
subplot(212);
plot2d(t,st);
plot2d3('gnn',n,sn);
xlabel('DT index n and time t=nts');
ylabel('Amplitude');
xtitle('Step response of analog and digital filter');