Professional Documents
Culture Documents
DSP
DSP
=
=
=
=
0:99;
cos (0.08 * pi * nn) ;
[1/3 1/3 1/3];
firfilt (bb,xx)
yy =
Columns 1 through 6
0.3333 0.6562 0.9483 0.8580 0.7137 0.5246
Columns 7 through 12
0.3025 0.0615 -0.1835 -0.4169 -0.6241 -0.7921
Columns 13 through 18
-0.9103 -0.9713 -0.9713 -0.9103 -0.7921 -0.6241
Columns 19 through 24
-0.4169 -0.1835 0.0615 0.3025 0.5246 0.7137
Columns 25 through 30
0.8580 0.9483 0.9791 0.9483 0.8580 0.7137
Columns 31 through 36
0.5246 0.3025 0.0615 -0.1835 -0.4169 -0.6241
Columns 37 through 42
-0.7921 -0.9103 -0.9713 -0.9713 -0.9103 -0.7921
Columns 43 through 48
-0.6241 -0.4169 -0.1835 0.0615 0.3025 0.5246
Columns 49 through 54
0.7137 0.8580 0.9483 0.9791 0.9483 0.8580
Columns 55 through 60
0.7137 0.5246 0.3025 0.0615 -0.1835 -0.4169
Columns 61 through 66
-0.6241 -0.7921 -0.9103 -0.9713 -0.9713 -0.9103
Columns 67 through 72
-0.7921 -0.6241 -0.4169 -0.1835 0.0615 0.3025
Columns 73 through 78
0.5246 0.7137 0.8580 0.9483 0.9791 0.9483
Columns 79 through 84
0.8580 0.7137 0.5246 0.3025 0.0615 -0.1835
Columns 85 through 90
-0.4169 -0.6241 -0.7921 -0.9103 -0.9713 -0.9713
Columns 91 through 96
-0.9103 -0.7921 -0.6241 -0.4169 -0.1835 0.0615
Columns 97 through 102
0.3025 0.5246 0.7137 0.8580 0.6150 0.3229
bb = [1/2,1/2]
ww = -pi : pi/100 : pi
H = freqz (bb,1,ww);
plot (ww,abs(H));grid
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
-4
-3
-2
-1
1
0.8
0.6
0.4
0.2
0
-4
-3
-2
-1
-3
-2
-1
4
2
0
-2
-4
-4
0
Frequency
A = 7;
fi = pi/3;
W = .125*pi;
n = 0:49;
xx = A * cos ((W*n)+fi);
bb = [5 -5];
yy = firfilt(xx,bb);
(a)
A = 7;
fi = pi/3;
W = .125*pi;
n = 0:49;
xx = A * cos ((W*n)+fi);
bb = [5 -5];
yy = firfilt(xx,bb)
subplot(2,1,1)
stem (n,xx);grid on
xlabel ('0<n<49')
title ('Magnitude and Phase of X')
subplot(2,1,2)
stem(n,yy(1:50));grid on
xlabel ('0<n<49')
title ('Magnitude and Phase of Y')
10
15
10
15
20
25
30
35
0<n<49
Magnitude and Phase of Y
40
45
50
40
45
50
20
10
0
-10
-20
20
25
0<n<49
30
35
Amplitude of X is 6.9043.
frequency = pi/16
amplitude = 13
phase = pi/8
(f)
hold off
mag of X and Y
20
15
10
5
0
10
15
20
25
30
35
40
45
50
35
40
45
50
angle of X and Y
4
3
2
1
0
10
15
20
25
30
(g)
W = .125*pi; n = 0:49;
xx = exp (j*W*n);
bb = [5 -5];
yy = firfilt(xx,bb)
subplot(2,1,1)
stem (n,xx);grid on
xlabel ('0<n<49')
title ('Magnitude and Phase of X')
subplot(2,1,2)
stem(n,yy(1:50));grid on
xlabel ('0<n<49')
title ('Magnitude and Phase of Y')
10
15
10
15
20
25
30
35
0<n<49
Magnitude and Phase of Y
40
45
50
40
45
50
6
4
2
0
-2
20
25
0<n<49
30
35
10
15
10
15
20
25
30
35
0<n<49
Magnitude and Phase of Y
40
45
50
40
45
50
6
4
2
0
-2
20
25
0<n<49
30
35
(b,c)
plot (n,error,'r')
hold off
100
50
0
-50
-100
10
15
20
25
30
35
40
45
50
10
15
20
25
30
35
40
45
50
100
50
0
-50
-100
error =
2.4869e-14
3.4 Time-Invariance of the Filter:
yy
20
0
-20
10
15
20
25
30
35
40
45
50
30
35
40
45
50
30
35
40
45
50
ys
50
0
-50
10
15
20
25
yy and ys
50
0
-50
10
15
20
25
13.0848
4.1172
21.4413
54.9089
84.9152
43.0911
13.0848
4.1172
21.4413
76.5587
43.0911
13.0848
84.9152
93.8828
76.5587
21.4413
54.9089
84.9152
Columns 7 through 12
93.8828
76.5587
Columns 13 through 18
54.9089
84.9152
93.8828
Columns 19 through 24
4.1172
21.4413
54.9089
Columns 25 through 30
43.0911
13.0848
Columns 31 through 36
4.1172
93.8828
76.5587
43.0911
13.0848
4.1172
21.4413
76.5587
43.0911
13.0848
84.9152
93.8828
76.5587
Columns 37 through 42
54.9089
84.9152
93.8828
Columns 43 through 48
4.1172
21.4413
54.9089
Columns 49 through 51
43.0911
13.0848
0.8348
(b)
X
10
0
-10
10
15
20
25
30
35
40
45
50
Y
100
50
0
10
15
20
25
30
35
40
45
50
10
15
20
25
30
35
40
45
50
50