0% found this document useful (0 votes)
139 views

LAB # 05 Frequency Analysis

The document discusses analyzing discrete-time systems using Fourier analysis. It provides 6 examples of difference equations and filters, analyzing their magnitude and phase response as well as pole-zero plots. Properties of the discrete Fourier transform, including linearity and time shifting, are also demonstrated. Linear systems are shown to have Fourier transforms that are the sum of scaled transforms, and a time shift is shown to correspond to a phase shift in the frequency domain.

Uploaded by

zohaib khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

LAB # 05 Frequency Analysis

The document discusses analyzing discrete-time systems using Fourier analysis. It provides 6 examples of difference equations and filters, analyzing their magnitude and phase response as well as pole-zero plots. Properties of the discrete Fourier transform, including linearity and time shifting, are also demonstrated. Linear systems are shown to have Fourier transforms that are the sum of scaled transforms, and a time shift is shown to correspond to a phase shift in the frequency domain.

Uploaded by

zohaib khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

LAB # 05

FREQUENCY ANALYSIS
Introduction
If x(n) is absolutely summable, that is
transform is given by

then its discrete-time Fourier

The inverse discrete-time Fourier transform (IDTFT) of X(ejw) is given by

1. Fourier anaylsis of discrete systems described by difference equation provide the plots for the
following along with the title of each by matching its response to Low pass, high pass, band pass
or band stop filter. Also include in the title whether the system is FIR or IIR. The frequency
response can be obtained using freqz(num,den). Poles and zero plot is obtained using
zplane(num,den). Comment on the poles and zeros location of each filter.
a. Y[n] = 0.08x[n] + 0.34x[n-1] + 0.34x[n-2] + .34x[n-3] + 0.08x[n]
b = [0.08 0.34 0.34 0.34 0.08];
subplot(2,1,1), freqz(b,1)
subplot(2,1,2), zplane(b,1)

b. Y[n] 1.11y[n-1] + 0.57 y[n-2] = x[n] + 2x[n-1] + x[n-2]


b = [ 1 2 1];
a = [1 -1.11 0.57 ];
figure
subplot(2,1,1), freqz(b,a)
subplot(2,1,2), zplane(b,a)

c. Y[n] = -0.21x[n] -0.17x[n-1] + 0.81x[n-2] -0.17x[n-3] -0.21x[n-4]


b = [-0.21 -0.17 0.81 -0.17 -0.21];
figure
subplot(2,1,1), freqz(b,1)
subplot(2,1,2), zplane(b,1)

d. Y[n] 1.11y[n-1] + 0.57y[n-2] = x[n] 2x[n-1] + x[n-2]


b = [1 -2 1];

a = [ 1 -1.11 0.57];
figure
subplot(2,1,1), freqz(b,a)
subplot(2,1,2), zplane(b,a)

e. Y[n] = -0.35x[n] + 0.2x[n-1] -0.07x[n-2] + 0.20x[n-3] 0.35x[n-4]


b = [-0.35 0.20 -0.07 0.20 -0.35];
figure
subplot(2,1,1), freqz(b,1)
subplot(2,1,2), zplane(b,1)

f. 2y[n] + 1.63y[n-1] + 0.65y[n-2] = x[n] x[n-2]


b = [ 1 0 -1];
a = [2 1.63 0.65];
figure
subplot(2,1,1), freqz(b,a)
subplot(2,1,2), zplane(b,a)

Determine the Magnitude and Phase response of the following Difference Equation.

3y[n]+1.5y[n-1]+2y[n-3]=x[n]+4x[n-1]+2x[n-3]
clc;
clear all;
close all;
B=input('Enter Numerator coefficients');
A=input('Enter Denominator coefficients');
w=-pi:pi/255:pi;
H=freqz(B,A,w);
magnitude=abs(H);
phase=angle(H);
figure;
subplot(2,1,1);
plot(w,magnitude);
title('magnitude plot/Zohaib/13EE018');
xlabel('w in radians/sample');
ylabel('|H(w)|');
subplot(2,1,2);
plot(w,phase);
title('phase plot');
xlabel('w in radians/sample');
ylabel('<H(w)');

magnitude plot/zohaib/13EE018

|H(w)|

3
2
1
0
-4

-3

-2

-1
0
1
w in radians/sample
phase plot

-3

-2

-1
0
1
w in radians/sample

<H(w)

2
0
-2
-4
-4

Example:

X(n)=cos(2*pi*n/100)
Code:
clear all
clc
n=0:29;
x=cos(2*pi*n/100)
n1=64
n2=126
n3=256
x1=abs(fft(x,n1))
x2=abs(fft(x,n2))
x3=abs(fft(x,n3))
f1=[0:n1-1]/n1
f2=[0:n2-1]/n2
f3=[0:n3-1]/n3
subplot(1,3,1)
plot(f1,x1)
title('n=64/ Zohaib/13EE018')
subplot(1,3,2)
plot(f2,x2)

title('n=126')
subplot(1,3,3)
plot(f3,x3)
title('n=256')
n=64/zohaib/ 13EE018
16

16

14

14

14

12

12

12

10

10

10

0.5

n=126

0.5

n=256

16

0.5

2. Properties of DTFT
In this part fft(x,n) function will be used to prove some of the Fourier transform
properties.

a. Linearity
The discrete-time Fourier transform is a linear transformation; that is,

For every , , x1(n), and x2(n)


close all, clear all
n = -2*pi:.01:2*pi;
size(n);
x1=sin(10*2*pi*n);
x2=sin(20*2*pi*n);

y1 = 10*x1;
y2 = 5*x2;
Y1 = abs(fft(y1));
Y2 = abs(fft(y2));
subplot(3,1,1) , plot(Y1+Y2)
title('F[aX1 + bX2]/ Zohaib/13EE018');
X1 = abs(fft(x1));
X2 = abs(fft(x2));
X1 = 10*X1;
X2 = 5*X2;
subplot(3,1,2) , plot(X1+X2)
title('aF[X1] + bF[X2]');
diff = X1 + X2 - (Y1 + Y2);
subplot(3,1,3) , plot(diff)
title('aF[X1] + bF[X2] - F[aX1 + bX2]');
F[aX1 + bX2]/zohaib/13EE018

10000
5000
0

200

400

600

800

1000

1200

1400

1000

1200

1400

1200

1400

aF[X1] + bF[X2]

10000
5000
0

200
-12

400

600

800

aF[X1] + bF[X2] - F[aX1 + bX2]

x 10

0
-2

200

400

600

800

1000

b. Time shifting
A shift in the time domain corresponds to the phase shifting

close all, clear all


x = rand(1,11);
n = 0:10;
k = 0:500;
w = (pi/500)*k;

X = x*(exp(-j*pi/500)).^(n'*k);
% X signal shifted by samples
y =x;
m = n+20;
Y = y*(exp(-j*pi/500)).^(m'*k);
% X verification
Y_check = (exp(-j*20).^w).*X;
subplot(2,1,1), plot(abs(X))
title('time shifting/ zohaib /13EE018');
subplot(2,1,2), plot(abs(Y))
error = max(abs(Y-Y_check))
time shifting/ zohaib /13EE018

8
6
4
2
0

100

200

300

400

500

600

100

200

300

400

500

600

8
6
4
2
0

You might also like