Digital Signal Processing
Lab 3
Exercise 1
Low pass filter
Fs = 8000; % Sample everything at 8000 Hz
Fo1 = 660; % Use 660 Hz as the fundamental freq of each waveform
Fo2 = 3900; % Use 660 Hz as the fundamental freq of each waveform
T_total = 1.2; % Compute a total of 1.2 seconds so the sound can be played
tt = 0:(1/Fs):T_total; % Set up the time axis
% ===== First the cosine =====
y1 = cos(2*pi*Fo1*tt)+0.5*cos(2*pi*Fo2*tt);
y2 = filter([1], [1 -0.8], y1);
range = 801:880; % Only plot a part of the signal
figure(1)
subplot(2,1,1)
plot(tt(range),y1(range))
xlabel('TIME (sec)')
title('y1')
%sound(y1, Fs)
subplot(2,1,2)
plot(tt(range),y2(range))
xlabel('TIME (sec)')
title('y2')
H = 0;
w=-pi:pi/500:pi;
for k=1:length(y1) % sum(hk exp(-jkw)
H = H + y1(k)*exp(-j*(k-1)*w);
end
mag=abs(H);
figure(2)
plot(w,mag)
axis([-pi pi 0 max(mag)])
%
H = 0;
w=-pi:pi/500:pi;
for k=1:length(y2) % sum(hk exp(-jkw)
H = H + y2(k)*exp(-j*(k-1)*w);
end
mag=abs(H);
figure(3)
plot(w,mag)
axis([-pi pi 0 max(mag)])
Exercise 2
High pass filter
Change the y2 to be
y2 = filter([1 -0.6], [1], y1);
Sources:
Fundamentals of Digital Signal Processing, by Joyce Van de Vegte, Prentice Hall, 2002.