Lab Assignment IV (Dec 17th, 2014)

advertisement
Dec 16th, 2014
IZMIR UNIVERSITY OF ECONOMICS
EEE 301 LABORATORY ASSIGNMENT IV
In this assignment, you will learn to simulate frequency-domain low-pass and high-pass filtering
of a given music signal by using the Fourier transform in Matlab.
BACKGROUND:
For continuous-time signals, the Fourier transform synthesis and analysis equations are given
respectively as:
x(t ) 
1
2



X ( jw)e jwt dw

X ( jw)   x(t )e  jwt dt

While the continuous-time Fourier series can represent periodic signals as a weighted ({ak}) sum
of complex exponentials occur at a discrete set of harmonically related frequencies {kw0}, the
Fourier transform describes aperiodic signals as a linear combination of complex exponentials
occur at a continuum of frequencies with amplitude X ( jw)dw / 2 .
The response of an LTI system with impulse response h(t) to an input signal x(t) can be
determined using the Fourier transform as
y (t ) 
1
2



X ( jw) H ( jw)e jwt dw
where H(jw) is the frequency response of the system, and
Y ( jw)  X ( jw) H ( jw).
For frequency-selective filtering, frequency response of the LTI system can be designed such that
H ( jw)  1 over one range of frequencies and H ( jw)  0 over another range of frequencies.
The frequency response magnitude of ideal low-pass and high-pass filters are given below:
ASSIGNMENT:
1. Read, plot and play the provided music file, lab4.wav, in Matlab as follows:
hfile = lab4.wav';
% Read the data back into MATLAB, and listen to audio.
[x, Fs, nbits, readinfo] = wavread(hfile);
sound(x, Fs);
t = linspace(0,16,length(x));
figure, plot(t,x)
2. Compute the Fourier transform of the music signal given in step 1. Note you can compute
approximation to CTFT either using fft() function in Matlab or using trapz() function for
numerical computation of the Fourier integral as follows:
w0 = [-100 : 1 : 100];
X = zeros(size(w0));
for i = 1 : length(w0)
X(i) = trapz(t,x.*exp(-j* w0(i)*t)); %Fourier Transform
end
figure, plot(w0,abs(X))
3. Next, simulate an ideal low-pass filter in frequency domain with a passband edge frequency at
Fs/8 and apply to the music signal. Plot the amplitude spectrum of the output and compare it with
the input amplitude spectrum plotted in step 2. Listen the output signal and comment on the effect
of filtering.
4. Then, simulate an ideal high-pass filter in frequency domain with the same passband edge
frequency in step 3 and apply to the music signal. Plot the amplitude spectrum of the output and
compare it with the input amplitude spectrum plotted in step 2. Listen the output signal and
comment on the effect of filtering.
Note: This example illustrates the use of fft() function in Matlab to compute and plot the
magnitude and phase of Fourier transform of a given signal:
%sampling frequency
Fs = 1000;
%sample time
T = 1/Fs;
%length of signal
L = 1000;
t = (0:L-1)*T;
%noisy input signal (sum of two sinusoids plus Gaussian noise)
x = sin(2*pi*50*t) + 0.5*sin(2*pi*120*t)+ 2*randn(size(t));
figure, plot(t,x),title('Signal with additive noise'),xlabel('Time
(samples)')
NFFT = 2^nextpow2(L);
%Fourier transform using fft()
X = fft(x,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
%plot single-sided amplitude spectrum
figure, plot(f,2*abs(X(1:NFFT/2))),title('Amplitude Spectrum')
xlabel('Frequency (Hz)')
%plot phase spectrum
figure, plot(f,angle(X(1:NFFT/2))),title('Phase Spectrum')
xlabel('Frequency (Hz)')
Download