Sunteți pe pagina 1din 7

EEE420 Lab Handout

LAB # 5 HANDOUT
1. FAST FOURIER TRANSFORM

Data Sequence A0 = x0 , x1 , x 2 , x3 , x 4 , x5 , x6 , x7 The N-point DFT is converted


into two DFTs each of N/2
points.
x0 , x 2 , x 4 , x6 x1 , x3 , x5 , x7
WN=e-j2/N
x0 , x 4 x 2 , x6 x1 , x5 x3 , x 7 WN2=WN/2
WN(k+N/2)= -WNk
Then, the following formulas must be used.

X 1 (k ) = X 11 (k ) + W Nk X 12 (k ) k=0,.....,7

k=0,1,2,3 k=0,1,2,3
X 11 (k ) = X 21 (k ) + W Nk / 2 X 22 (k ) X 12 (k ) = X 23 (k ) + W Nk / 2 X 24 (k )

k=0,1 k=0,1 k=0,1 k=0,1


X 21 (k ) = x0 + W Nk / 4 x 4 X 22 (k ) = x 2 + W Nk / 4 x 6 X 23 (k ) = x1 + WNk / 4 x5 X 24 (k ) = x3 + W Nk / 4 x7
X21(0)= x0 + x4 X22(0)= x2 + x6 X23(0)= x1 + x5 X24(0)= x3 + x7
X21(1)= x0 - x4 X22(1)= x2 x6 X23(1)= x1 x5 X24(1)= x3 x7

X 11 (0 ) = X 21 (0 ) + X 22 (0 ) X 12 (0 ) = X 23 (0 ) + X 24 (0 )
X 11 (1) = X 21 (1) jX 22 (1) X 12 (1) = X 23 (1) jX 24 (1)
X 11 (2 ) = X 21 (0 ) X 22 (0 ) X 12 (2 ) = X 23 (0 ) X 24 (0 )
X 11 (3) = X 21 (1) + jX 22 (1) X 12 (3) = X 23 (1) + jX 24 (1)

By using fft and ifft functions in matlab:

In command window:

>> x=[ 1 1 0 0 0 0 1 1]
x =
1 1 0 0 0 0 1 1
>> fft(x)
ans =
Columns 1 through 8
4.0000 2.4142+1.0000i 0 -0.4142-1.0000i 0 -
0.4142+1.0000i 0 2.4142-1.0000i
>> ifft(ans)
ans =
1.0000 1.0000 0 0 0.0000 0
1.0000 1.0000

1
EEE420 Lab Handout

2. THE BUTTERFLY

X21(0) X11(0) = X21(0) + W80 X22(0)

X22(0)
W80 X11(2) = X21(0) - W80 X22(0)
FFT Butterflies
X21(1) X11(1) = X21(1) + W82 X22(1)

X22(1) W82 X11(3) = X21(1) - W82 X22(1)

The butterfly that shows all of the connections is shown below:

x0 X21(0) X1(0)
X11(0)

x4 X21(1) W80 X11(1) X1(1)

x2 X22(0) X11(2) X1(2)


2
W 8

x6 X22(1) X11(3) X1(3)

x1 X23(0) W80
X12(0) X1(4)

0
W81
x5 X23(1) W 8 X12(1) X1(5)
2
x3 X24(0) X12(2) W8 X1(6)
W82
x7 X12(3) W83 X1(7)
X24(1)

2
EEE420 Lab Handout

3. SAMPLING OF A SINUSOIDAL SIGNAL


In this program we will investigate the sampling of a continuous-time sinusoidal signal
xa(t) at various sampling rate. Since MATLAB cannot strictly generate a continuous-
time signal, we will generate a sequence {xa(nTH)} from xa(t) by sampling it at a very
high rate TH such that the samples are very close to each other. A plot of xa(nTH)
using the plot command will then look like a continuous-time signal.

As a result, x[n] is generated by periodically sampling Xa(t) at uniform time interval T.

x[n]= Xa(n,T)

T=sampling interval
Fs=sampling rate, sampling frequency= 1/T

M-file:

% Illustration of the Sampling Process in the Time-Domain

clf; % Clear current figure


clear all; % Clear all variables
%--------------------------------------------------------
% Generation of the continuous-time signal
%------------------------------------------------------
t = 0 : 0.0005 : 1;
f = 13;
xa = cos(2*pi*f*t);
subplot(2,1,1)
plot(t,xa);grid
xlabel('Time, msec');
ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
axis([0 1 -1.2 1.2]);
subplot(2,1,2)
%--------------------------------------------------------
% Sampling in time-domain
%------------------------------------------------------
T = 0.1;
n = 0 : T : 1;
xs = cos(2*pi*f*n);
k = 0 : length(n)-1;
stem(k,xs,'r');grid
xlabel('Time index n');
ylabel('Amplitude');
title('Discrete-time signal x[n]');
axis([0 length(n)-1 -1.2 1.2])

3
EEE420 Lab Handout

Continuous-time signal x a(t)

0.5

Amplitude
0

-0.5

-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time, msec
Discrete-time signal x[n]
1

0.5
Amplitude

-0.5

-1
0 1 2 3 4 5 6 7 8 9 10
Time index n

4. ALIASING EFFECT IN THE TIME-DOMAIN


In this program we will generate a continuous-time equivalent ya(t) of the discrete-
time signal x[n] generated in previous program to investigate the relation between the
frequency of the sinusoidal signal xa(t) and sampling period. To generate the
reconstructed signal ya(t) from x[n], we pass x[n] through an ideal lowpass filter. The
higher frequency analog signal can be reconstructed in lower freq. form after
sampling.
Formula of Reconstruction:


Xa(t ) = x(n).sinc[Fs(t nTs)]
n =

To prevent aliasing fs>2f0.

The colors of the plots: Some other representations:


b represents blue o represents circle
g represents green * represents star
r represents red .
c represents cyan .
m represents magenta .
y represents yellow
k represents black

4
EEE420 Lab Handout

M-file:

% Illustrating of Aliasing Effect in the Time-Domain

clf;
clear all;
T = 0.1;
f = 13;
n = (0:T:1)';
xs = cos(2*pi*f*n);
%------------------------------------------------------
%linspace(x1,x2,N) generates N points between x1 and x2.
%for N<2, linspace returns x2.
%------------------------------------------------------
t = linspace(-0.5,1.5,500)';
%------------------------------------------------------
%reconstruction formula is shown below.
%------------------------------------------------------
ya = sinc((1/T)*t(:,ones(size(n))) -
(1/T)*n(:,ones(size(t)))')*xs;
plot(n,xs,'o',t,ya);grid;
xlabel('Time index n');
ylabel('Amplitude');
title('Reconstructed continuous-time signal y_{a}(t)');
axis([0 1 -1.2 1.2])
Reconstructed continuous-time signal y a(t)

0.8

0.6

0.4

0.2
Amplitude

-0.2

-0.4

-0.6

-0.8

-1

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


Time index n

5
EEE420 Lab Handout

5. EFFECT OF SAMPLING IN THE FREQUENCY-DOMAIN


In order to convert a continuous-time signal xa(t) into an equivalent discrete-time
signal x[n], the former must be band-limited in the frequency-domain. To illustrate the
effect of sampling in the frequency-domain we choose an exponentially decaying
continuous-time signal with a CTFT that is approximately band-limited.
M-file:

% Illustrating of the Aliasing Effect


% In the Frequency-Domain
clf;
clear all;
%--------------------------------------------------------
% Generation of the continuous-time signal
%--------------------------------------------------------
t = 0 : 0.005 : 10;
xa = 2*t.*exp(-t);
subplot(2,2,1)
plot(t,xa);grid % grid is used for grid lines
xlabel('Time, msec');
ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');
subplot(2,2,2)
wa = 0 : 10/511 : 10;
%--------------------------------------------------------
% H=freqs(B,A,W) returns the complex frequency response
% vector H of the filter B/A; the frequency response is
% evaluated at the points specified in vector W.
%--------------------------------------------------------
Ha = freqs(2,[1 2 1],wa);
plot(wa/(2*pi),abs(Ha));grid
xlabel('Frequency, KHz');
ylabel('Amplitude');
title('|X_{a}(j\Omega)|');
axis([0 5/pi 0 2]);
subplot(2,2,3)
%--------------------------------------------------------
% Sampling of the signal
%--------------------------------------------------------
T = 1;
n = 0 : T : 10;
xs = 2*n.*exp(-n);
k = 0 : length(n)-1;
stem(k,xs);grid;
xlabel('Time index n');
ylabel('Amplitude');
title('Discrete-time signal x[n]');
subplot(2,2,4)
wd = 0 : pi/255 : pi;

6
EEE420 Lab Handout

%--------------------------------------------------------
% H=freqz(B,A,W) returns the frequency response at
% frequencies designated in vector W.
%--------------------------------------------------------
Hd = freqz(xs,1,wd);
plot(wd/(T*pi),T*abs(Hd));grid;
xlabel('Frequency, KHz'); ylabel('Amplitude');
title('|X(e^{j\Omega})|');
axis([0 1/T 0 2]);

Continuous-time signal x a(t) |Xa(j )|


0.8 2

0.6 1.5
Amplitude

Amplitude

0.4 1

0.2 0.5

0 0
0 5 10 0 0.5 1 1.5
Time, msec Frequency, KHz
Discrete-time signal x[n] |X(ej )|
0.8 2

0.6 1.5
Amplitude

Amplitude

0.4 1

0.2 0.5

0 0
0 5 10 0 0.5 1
Time index n Frequency, KHz

S-ar putea să vă placă și