PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

500 Practical MATLAB® Applications for Engineers


R.5.130 The MATLAB command fft2(f) where f is an n by m matrix returns the 2-D fft of
the elements of f, where f may represent, for example, a 2-D matrix representing
a picture (video) where each element may be a dot (pixel) with varying degrees
of intensities (white–gray–black), for a white-and-black image. The fft2 returns
fi rst the fft of each column of f, then the fft of each row of the resulting matrix,
resulting in a complex n by m DFT matrix. The command ifft2(F) returns the
2-D IDFT.


R.5.131 The MATLAB command F = fftn(f) returns the n-dimension DFT of the n- dimension
array f.


R.5.132 The MATLAB command f = iffn(F) returns the n- d i m e n s i o n a l I D F T o f t h e n- dimension
array F.


R.5.133 Since DFT is a linear transform, the fft2 can also be viewed as tak i ng fi rst the trans-
form of each of the rows and then the transforms of the columns of the resulting
matrix.


R.5.134 Let us summarize some facts about the fft.


The fft is not a new transform but rather an effi cient computational algorithm that
returns the DFT of an arbitrary fi nite discrete-time sequence. The computational
effi ciency of the fft is based on the following facts:
a. The DFT is periodic with the period extending over 2π, from −π to +π.
b. If the number of samples is N, and they are all real, then the required range of
DFT is over N/2.
c. When the discrete-time sequence f(n) is a real sequence, the transform coeffi -
cients through Fm are complex conjugate of FN−m, for any 0 ≤ m ≤ N/2.
d. It can be shown that all the values outside the set of transforms F 0 , F 1 , F 2 , ..., FN/2
are redundant.


R.5.135 The MATLAB command fftshift(F) returns the frequency-spectrum components
centered in the middle in which half of the frequencies is positive and the other
half negative.


R.5.136 The MATLAB command ifftshift(F) undoes the effects of fftshift(F).


R.5.137 For example, let fn_8 = [1 2 3 4 5 6 7 8] be an eight-sample sequence.


a. Evaluate the DFT of fn_8 by using MATLAB.
b. Observe that F 3 = F 5 * (recall that the character * denotes the complex conjugate).
c. Let fn_4 = [1 2 3 4], and evaluate its DFT and observe its symmetry.
d. Inverse the sequence fn_8, and call the new sequence as fn_8_i = [8 7 6 5 4 3 2 1].
Verify that reversing the sequence in time is equivalent of evaluating the
complex conjugate of the DFT of the original time sequence fn_8.
e. Create the sequence fn_4_0 = [1 2 3 4 0 0 0 0], evaluate its DFT, and compare the
results with DFT of fn_4.
f. Let f_ 3by3 = magic(3) matrix and evaluate its DFT using the fft command.
g. Let f_ trans_ 3by3 = (magic(3))’ matrix and evaluate its DFT by using the fft
function, and compare the results obtained with part f.
h. Repeat parts g and f by using the fft2 function, verifying the linearity
pro perty.
Free download pdf