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

DSP Lab 2

. Determine the Fourier transform of the following sequence. Use the FFT (Fast Fourier Transform) function

Uploaded by

HunZilah ShEikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

DSP Lab 2

. Determine the Fourier transform of the following sequence. Use the FFT (Fast Fourier Transform) function

Uploaded by

HunZilah ShEikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Digital Signal Processing

Lab 2

Name: Muhammad Hunzilah Ahmad


Session: BSEE 2018-2022(Electronics)

Instructors: Dr. Sufi Tabassum Gul

Engr. Javeria Ayub


Engr. Ayesha Ashraf

Pakistan Institute of Engineering and Applied Sciences, Islamabad


2.1`Objectives
• Plot the magnitude and phase of the system.
• Plot the real and imaginary parts of the system function by using coefficients.
• Computation of DTFT and FFT using MATLAB.
2.2 Equipment
• Computer / laptop
• MATLAB software
2.3 Useful Matlab functions
• fft,freqz, real, imag, abs, angle
• subplot, input
2.4 Tasks
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}

%task 1 fft of sequence given


n = input('Enter length of sequence');

for i=1:n
x(i) = input('Enter the element');
end
disp('Sequence x[n] = ')
disp(x)

y=fft(x,2.^n);

subplot(2,1,1);
plot(abs(y));
title('Magnitude of System')
xlabel('Frequency')
ylabel('Magnitude')

subplot(2,1,2);
plot(angle(y));
title('Phase of System')
xlabel('Frequency')
ylabel('Phase')
Figure 1 Fourier transform of the given sequence

2. Compute the discrete time Fourier transform of the following function analytically and
then Plot the magnitude and phase
x(n) = 𝟑(𝟎. 𝟗)𝒏 𝒖(𝒏)
Analytical calculation
Plotting the magnitude and phase
w = -pi : 0.1 : pi;
y = 3./(1-0.9*exp(-1i*w));
%%Magnitude Response of FFT of system
subplot (2,1,1)
plot (w,abs(y))
title ('Response of Magnitude ')
xlabel('Frequency')
ylabel('Magnitude')

%%Phase Response of FFT of system


subplot (2,1,2)
plot (w,angle(y))
title('Response of Phase')
xlabel('Frequency')
ylabel('Magnitude')

Figure 2 Fourier transform of the function


3. Determine H(w) and plot its magnitude and phase for the following system.
y(n) = 2x(n) + x(n-1) – 0.25y(n-1) + 0.25y(n-2)

w = -pi: 1/ (50*2*pi) :pi;


num = [2 1];
den = [1 0.25 -0.25];
f = freqz (num, den, w);

subplot (2,1,1)
plot( w ,abs (f))
title ('magnitude ')
xlabel ('frequency')
ylabel ('Amplitude')
subplot (2,1,2)
plot( w ,phase (f))
title (' phase ')
xlabel ('frequency')
ylabel ('Amplitude')
Figure 3 magnitude and phase for the H(w) of system

4. Given below is the frequency response of the system,


𝟏+𝐞−𝐣𝐰
H(ejw) = 𝟏−𝐞−𝐣𝐰+𝟎.𝟗𝐞−𝐣𝟐𝐰

a) Write a MATLAB code that manually implements the above system.


b) Compare with the spectrum obtained from freqz command
%manually implements the above system.
w = -pi:0.1 :pi;
H_w = (1+exp(-1i*w))./(1-exp (-1i*w) +0.9*exp(-2i*w));

subplot (4,2,1)
plot (w, abs (H_w))
title('Magnitude Response')
xlabel('Frequency')
ylabel('Magnitude')

subplot (4, 2, 2)
plot (w, angle (H_w))
title ('Phase Response')
xlabel ('Frequency')
ylabel('Magnitude')

subplot (4,2,3)
plot (w, real (H_w))
title('Real Response')
xlabel('Frequency')
ylabel('Real Value')

subplot (4,2,4)
plot (w, imag (H_w))
title ('Imaginary Response')
xlabel ('Frequency')
ylabel('Imaginary Value')

%implement using freqz command the above system.


num = [1 1];
den = [1 -1 0.9];
f = freqz (num, den, w);

subplot (4,2,5)
plot (w, abs (f))
title('Magnitude Response')
xlabel ('Frequency')
ylabel('Magnitude')

subplot (4,2,6)
plot (w, angle (f))
title('Phase Response')
xlabel('Frequency')
ylabel ('Magnitude')

subplot (4, 2,7)


plot (w, real (f))
title ('Real Component')
xlabel ('Frequency')
ylabel('amplitude')

subplot (4, 2,8)


plot (w, imag (f))
title ('imaginary Component')
xlabel ('Frequency')
ylabel('amplitude')
Figure 4 manually implements the above system

Figure 5 spectrum obtained from freqz command

You might also like