Lab Manaual 07: University of Engineering and Technology, Taxila
Lab Manaual 07: University of Engineering and Technology, Taxila
LAB MANAUAL 07
Discrete-Time Signals
In the Frequency Domain
Lab Description:
Frequency Response:
The frequency response is a representation of the system's response to sinusoidal inputs at varying frequencies. The
output of a linear system to a sinusoidal input is a sinusoid of the same frequency but with a different magnitude and
phase. Any linear system can be completely described by how it changes the amplitude and phase of cosine waves
passing through it. This information is called the system's frequency response.Since both the impulse response and
the frequency response contain complete information about the system, there must be a one-to-one correspondence
between the two. Given one, you can calculate the other.The relationship between the impulse response and the
frequency response is one of the foundations of signal processing:A system's frequency response is the Fourier
Transform of its impulse response Since h [ ] is the common symbol for the impulse response, H [ ] is used for the
frequency response.
In general X(ejω) is a complex function of the real variable ω and can be written as
where Xre(ejω) and Xim(ejω) are, respectively, the real and imaginary parts of X(ejω), and are real
functions of ω. X(ejω) can alternately be expressed in the form
The quantity |X(ejω)| is called the magnitude function and the quantity θ(ω) is called the phase function
In many applications, the Fourier transform is called the Fourier spectrum and, likewise, |X(ejω)| and θ(ω)
are referred to as the magnitude spectrum and phase spectrum, respectively.
The DTFT X(ejω) is a periodic continuous function in ω with a period 2π. The DTFT satisfies a number
of useful properties that are often uitilized in a number of applications.
MATLAB COMMANDS:
For complex Z, the magnitude R and phase angle theta are given by:
R = abs (Z)
Theta = angle (Z)
Y = fft(X) returns the discrete Fourier transform of vector X, computed with a fast Fourier
transform (FFT) algorithm.
Y = fft(X)
Y = fft(X,n) returns the n-point FFT.
Y = fft(X, n)
Question No 01:
Compute the discrete Fourier transform of the following function analytically and Then plot the magnitude and
phase:
MATLAB Code:
w = [0:500]*pi/500;
z = exp(-j*w);
x = 3*(1-0.9*z).^(-1);
a = abs(x);
b = angle(x)*180/pi;
subplot(2,1,1);
plot(w/pi,a);
subplot(2,1,2);
plot(w/pi,b);
OUTPUT:
num=[2 1]
den=[1 –0.6]
MATLAB CODE:
subplot(2,2,4)
plot(w/pi,angle(h));
grid on;
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase, radians');
OUTPUT
The Fast Fourier Transform (FFT) is just a computationally fast way to calculate the DFT.
Question No 03:
Determine the Fourier transform of the following sequence. Use the FFT (Fast Fourier
Transform) function.
x (n) = {4 6 2 1 7 4 8}
MATLAB Code:
n = 0:6;
x = [4 6 2 1 7 4 8];
a = fft(x);
mag = abs(a);
pha = angle(a);
subplot(2,1,1);
plot(mag);
grid on
title('Magnitude Response');
subplot(2,1,2);
plot(pha);
grid on
title('phase Response');
OUTPUT:
x[n]----F-----X(ejw)
then, for the time-shifted sequences, a simple transformation of the index of summation in the
discrete-time Fourier transform yields
x[n-nd]----F-----e-jwndX(ejw)
Plot and compare the magnitude spectrum of the original input with time delayed input.
Plot and compare the phase spectrum of the original input with delayed input.
MATLAB CODE:
clc;
w = -pi:2*pi/255:pi;
D = 10;
num = [1 2 3 4 5 6 7 8 9];
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1));
grid on;
title('Magnitude Spectrum of Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2));
grid on;
title('Magnitude Spectrum of Time-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1));
grid on;
title('Phase Spectrum of Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2));
grid on;
title('Phase Spectrum of Time-Shifted Sequence')
Plot and compare the magnitude spectrum of the original input with frequency shifted input.
Plot and compare the phase spectrum of the original input with frequency shifted input..
MATLAB CODE:
clc;
w = -pi:2*pi/255:pi;
wo = 0.4*pi;
num1 = [1 3 5 7 9 11 13 15 17];
L = length(num1);
h1 = freqz(num1, 1, w);
n = 0:L-1;
num2 = exp(wo*i*n).*num1;
h2 = freqz(num2, 1, w);
subplot(2,2,1)
plot(w/pi,abs(h1));
grid on;
title('Magnitude Spectrum of Original Sequence')
subplot(2,2,2)
plot(w/pi,abs(h2));
grid on;
title('Magnitude Spectrum of Frequency-Shifted Sequence')
subplot(2,2,3)
plot(w/pi,angle(h1));
grid on;
title('Phase Spectrum of Original Sequence')
subplot(2,2,4)
plot(w/pi,angle(h2));
grid on;
title('Phase Spectrum of Frequency-Shifted Sequence')
OUTPUT
LAB TASK:
LAB EXERCISES:
1. Determine the Fourier transform of the following sequence. Use the FFT (Fast Fourier
Transform) function,
x(n) = {4 3 2 1 1 2 3 4}
2. Compute the discrete Fourier transform of the following function analytically and then
Plot the magnitude and phase
x(n) = 2(0.8)n+2 u(n-2)
3. Determine H(w) and plot its magnitude and phase for the following system.
H(ejw) = 1+e-jw
1-e-jw+0.9e-j2w
a) Write a MATLAB code that manually implements the above system.
b) Compare with the spectrum obtained from freqz command
Plot the magnitude and frequency spectrum.
Also plot real and imaginary plots