Problems 637
wherex[n]is the desired signal andη[n]is a noise that varies from 0 to 1 at random.
(a) LetA= 0 andx[n]=sign[cos(0.1πn)]. Determine how to processy[n], indicating the type of filter
to obtain an approximate version ofx[n]. Consider the first 100 samples ofx[n]and use MATLAB to
find the spectrum ofx[n]andy[n]to show that the filter you recommend will do the job.
(b)Use the MATLAB functionfir1to generate the kind of filter you decided to use above and show that
when filteringy[n]forA= 0 , you obtain the desired result.
(c) Consider the first 100 samples of the MATLAB file “handel.mat” a period of a signal that continuously
replays these values over and over. Letx[n]be the desired signal that results from this. Now let
A=0.01, and use the functionrandto generate the noise, and come up with suggestions as to how
to get rid of the effects of the multiplication by(− 1 )nand of the noiseη[n]. Recover the desired
signalx[n].
10.26. DFT of an aperiodic and periodic signal—MATLAB
Consider a signalx[n]=(−0.95)n(u[n]−u[n−70]).
(a) To compute the DFT ofx[n]we pad it with zeros so as to obtain a signal with length 2 γ, the larger but
closest to the length ofx[n]. Determine the value ofγand use the MATLAB functionfftto compute
the DFTX[k]of the padded-with-zeros signal. Plot its magnitude and phase.
(b)Let nowx 1 [n]=x[n−10]. Compute its DFTX 1 [k]using thefftfunction. Padx 1 [n]with zeros to
compute theγ-length FFT whereγis the value obtained above.
(c) Considerx[n]a period of a periodic signal of periodN= 70. Compute its DFT using thefftalgorithm
and then plot its magnitude and phase. What is the length of the FFT? Can we pad with zeros the
period to find its DFT?
10.27. Frequency resolution of DFT—MATLAB
When we pad an aperiodic signal with zeros, we are improving its frequency resolution—that is, the more
zeros we attach to the original signal the better the frequency resolution, as we obtain the frequency
representation at a larger number of frequencies around the unit circle.
(a) Consider an aperiodic signalx[n]=u[n]−u[n−10], and compute its DFT by means of thefftfunc-
tion padding it with 10 and then 100 zeros. Plot the magnitude response usingstem. Comment on
the frequency resolution of the two DFTs.
(b)When the signal is periodic, one cannot pad a period with zeros. When computing the FFT in theory
we generate a periodic signal of periodLequal or larger than the length of the signal when the signal
is aperiodic, but if the signal is periodic we must letLbe the signal period or a multiple of it. Adding
zeros to the period makes the signal different from the periodic signal. Considerx[n]=cos(πn/ 5 ),
−∞<n<∞as a periodic signal, and do the following:
n Consider exactly one period ofx[n]and compute the FFT of this sequence.
n Consider 10 periods ofx[n]and compute the FFT of this sequence.
n Consider attaching 10 zeros to one period and compute the FFT of the resulting sequence.
If we consider the first of these cases giving the correct DFT ofx[n], how many harmonic frequencies
does it show. What happens when we consider the 10 periods? Are the harmonic frequencies the
same as before? What are the values of the DFT in frequencies in between the harmonic frequencies?
What happened to the magnitude at the original frequencies. Finally, does the last FFT relate at all
to the first FFTs?
10.28. DFT and IIR filters—MATLAB
A definite advantage of the FFT is that it reduces considerably the computation in the convolution sum.
Thus, ifx[n], 0 ≤n≤N− 1 is the input of an FIR filter with impulse responseh[n], 0 ≤n≤M− 1 ,
their convolution sumy[n]=[x∗h][n]will be of lengthM+N− 1. Now ifX[k]andH[k]are the DFTs
(computed by the FFT) ofx[n]andh[n], and ifY[k]=X[k]H[k]is the DFT of the convolution sum of
length bigger or equal toM+N− 1 , then to be able to multiply the FFTsX[k]andH[k]they both should