Digital Signal Processing
Lab 2
Exercise 1
Fourier transform and the inverse Fourier transorm
1. Frequency response of the moving-average system (Page 44)
H = 0;
w=-pi:pi/5000:pi;
h = [1 1 1 1 1]/5;
for k=1:length(h) % transform
H = H + h(k)*exp(-j*(k-1)*w);
end
mag=abs(H);
phase=angle(H);
figure(1)
plot(w,mag)
axis([-pi pi 0 max(mag)])
figure(2)
plot(w,phase)
axis([-pi pi -pi pi])
h2 = zeros(size(h));
dw = 1/10000;
for k=1:length(h2) % inverse transform
h2(k) = sum(H.* exp(j*(k-1)*w) )*dw;
end
2. Ideal lowpass filter (Page 43)
wc = pi/3;
w=-pi:pi/5000:pi;
H = zeros(size(w));
t1 = round((-wc-(-pi))/(pi/5000))+1;
t2 = round((wc-(-pi))/(pi/5000))+1;
H(t1:t2) = ones(1, t2-t1+1);
mag=abs(H);
phase=angle(H);
figure(1)
plot(w,mag)
axis([-pi pi 0 max(mag)])
figure(2)
plot(w,phase)
axis([-pi pi -pi pi])
h2 = zeros(1, 30);
dw = 1/10000;
for k=1:length(h2) % sum(hk exp(-jkw)
h2(k) = sum(H.* exp(j*(k-1)*w) )*dw;
end
figure(3)
plot(1:length(h2),h2)
3. Square-summability for the ideal lowpass filter (Page 52)
h = h2;
H = 0;
for k=1:length(h) % sum(hk exp(-jkw)
H = H + h(k)*exp(-j*(k-1)*w);
if k > 1,
H = H + h(k)*exp(-j*(-(k-1))*w);
end
end
mag=abs(H);
phase=angle(H);
figure(4)
plot(w,mag)
axis([-pi pi 0 max(mag)])
figure(5)
plot(w,phase)
axis([-pi pi -pi pi])
Sources:
Fundamentals of Digital Signal Processing, by Joyce Van de Vegte, Prentice Hall, 2002.