LAB # 05 Frequency Analysis
LAB # 05 Frequency Analysis
FREQUENCY ANALYSIS
Introduction
If x(n) is absolutely summable, that is
transform 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)
a = [ 1 -1.11 0.57];
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,
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
x 10
0
-2
200
400
600
800
1000
b. Time shifting
A shift in the time domain corresponds to the phase shifting
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