EE511 Day 4 Class Notes Discussion of Visualization 1 Laurence Hassebrook

advertisement
EE511 Day 4 Class Notes
Discussion of Visualization 1
Laurence Hassebrook
Updated 9-5-03
Friday 9-5-03
Problem Satement: Use MATLAB to determine and plot the magnitude of the FFT of a rectangle
function, and a sine wave. The window size for the rectangle function should be 10 times its width
and the discrete frequency of the sine wave should be k=4.
DISCRETE COSINE FUNCTION
Given the following sequence
 k 
f n  cos 2 c n 
N 

for discrete time n = 0, 1, …., (N-1). N is the length of the sequence or the window size and kc is the
discrete frequency. For example: In matlab/pseudo code we would have
N=256;
n=0:(N-1);
kc=8;
f=cos(2*pi*kc*n/N)
The plot (ie., used plot(n,f)) for f is shown in Fig. 1.
1
The fft of Fig. 1 is the abs(fft(f)) shown in Fig. 2.
By using fftshift, the fft of Fig. 2 is shifted making look more like a continuous time Fourier
Transform. This is shown in Fig. 3 with k=n-N/2 where plot(k,abs(Fshifted)) was used.
RECTANGULAR WINDOWS AND FFT
A rectangular window is emulated in discrete time by wrapping it around the origin. The window
size is N and the rectangle width is N/10. For the fft to be real, the rectangle width must be an odd
integer and the rectangle must be wrapped around. The m file irect(Ty,Tx,My,Nx) will do that
operation. Assume N=256 so Tx=oddint(N/10)=oddint(25.6)=25. Then the matlab code is
2
w=irect(1,25,1,N);
plot(w);
The result is shown below in Fig. 4.
The fft of w is W and in Fig. 5 we show plot(real(W)) as:
3
Download