<< Chapter < Page | Chapter >> Page > |
Since the DFT is a sampled version of the spectrum of a digital signal, it has certain sampling effects. To explorethese sampling effects more thoroughly, we consider the effect of multiplying the time signal by different window functionsand the effect of using zero-padding to increase the length (and thus the number of sample points) of the DFT. Using thefollowing MATLAB script as an example, plot the squared-magnitude response of the following test cases overthe digital frequencies ${\omega}_{c}=\left[\frac{\pi}{8} , \frac{3\pi}{8}\right]$ .
Window sequences can be generated in MATLAB by using the
boxcar
and
hamming
functions.
1 N = 256; % length of test signals2 num_freqs = 100; % number of frequencies to test
34 % Generate vector of frequencies to test
56 omega = pi/8 + [0:num_freqs-1]'/num_freqs*pi/4;7
8 S = zeros(N,num_freqs); % matrix to hold FFT results9
1011 for i=1:length(omega) % loop through freq. vector
12 s = sin(omega(i)*[0:N-1]'); % generate test sine wave
13 win = boxcar(N); % use rectangular window14 s = s.*win; % multiply input by window
15 S(:,i) = (abs(fft(s))).^2; % generate magnitude of FFT16 % and store as a column of S
17 end18
19 clf;20 plot(S); % plot all spectra on same graph
21
Make sure you understand what every line in the script does. What signals are plotted?
You should be able to describe the tradeoff between mainlobe width and sidelobe behavior for the various window functions.Does zero-padding increase frequency resolution? Are we getting something for free? What is the relationship betweenthe DFT, $X(k)$ , and the DTFT, $X(\omega )$ , of a sequence $x(n)$ ?
In this section, you will resolve the two closely spaced sine waves using a Fourier transform method. Consider the signal:
consisting of two sine waves of frequency 2000 Hz and 2100 Hz with sampling frequency of 8000 Hz. Here, n is the discrete time index.
Generate a block of 256 samples of x(n) and use the Fast Fourier Transform (fft) command to determine the two frequency components.
What is the closest frequency to 2000 Hz that you can resolve using the Fourier transform method? Which of the following method applied to x(n) results in the best resolving capabilities? Why?
The following Matlab code can be used to generate a pure tone:
fs = 8000; %sampling rate
duration = 1; % sect = linspace(0, duration, duration * fs); % time axis
freq = 600; % Hzx = sin(2*pi*freq*t);
To listen to it, you can use:
soundsc(x, fs)
This will be useful for testing purposes in Lab 4.
Short-time spectral analysis is an important technique that is used to visualize the time evolution of the frequency content of non-stationary signals, such as speech. The fundamental assumption is that the signal is modeled as being quasi -stationary over short time periods; in many speech applications, this period is on the order of 20-30 milliseconds.
The short-time Fourier transform (STFT) is defined to be:
In the case of digital time and frequency, the rate at which τ is evaluated, along with the block size used to compute the FFT determines the amount of data overlap that occurs in evaluating the STFT over time.
The spectrogram is just the magnitude-squared of the STFT, and can be computed in MATLAB:
spectrogram(x, nwin, noverlap);
which computes the STFT using a Hamming window of length nwin, every
nwin-noverlap
samples. The question of how much to overlap can be understood by asking how many time/frequency samples are required to
fully represent the continuous time-frequency STFT; for the interested reader, see the section titled "Analysis of Short Term Spectra" in
[Allen77] .
Plot the spectrogram of the first two signals you generate in part 2 with no overlap and 50% overlap. How are the spectrograms different between the two methods?
For students in the Wednesday and Thursday sections: repeat this for the the following frequency-sweep signal:
s = chirp(0:1/8000:0.5,1000,0.5,5000);
Type
doc chirp
to understand the input arguments to the chirp function. What is going on at 0.4 seconds into the signal?
Notification Switch
Would you like to follow the 'Ece 420 spring 2014' conversation and receive update notifications?