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

Lab 5

This document describes 3 MATLAB tasks to perform the forward and inverse discrete Fourier transform (DFT) on time domain and frequency domain sequences. Task 1 develops code to calculate the forward DFT of a time domain sequence using a matrix formulation, and plots the magnitude and phase spectra. Task 2 calculates the inverse DFT of a frequency domain sequence using matrix inversion. Task 3 calculates the inverse DFT using the conjugate method instead of matrix inversion.

Uploaded by

Kinza Mallick
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)
20 views

Lab 5

This document describes 3 MATLAB tasks to perform the forward and inverse discrete Fourier transform (DFT) on time domain and frequency domain sequences. Task 1 develops code to calculate the forward DFT of a time domain sequence using a matrix formulation, and plots the magnitude and phase spectra. Task 2 calculates the inverse DFT of a frequency domain sequence using matrix inversion. Task 3 calculates the inverse DFT using the conjugate method instead of matrix inversion.

Uploaded by

Kinza Mallick
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/ 3

KINZA PERVEZ

EE-20141
LAB SESSION 5

TASK#1:

Forward DFT using matrices.


Develop a MATLAB code to find the Forward DFT output of the following time domain
sequence by using the DFT equation in matrix form. Also, plot the magnitude and phase
spectrum. Take 𝐹𝑠=1000 𝑠𝑎𝑚𝑝𝑙𝑒𝑠/sec
𝑥(𝑛)= {0.3535,0.3535, 0.6464, 1.0607, 0.3535, −1.0607, −1.3535, −0.3535}
close all,clear all;clc;

x = [0.3535, 0.3535, 0.6464, 1.0607, 0.3535, -1.0607, -1.3535 , -0.3535];


N = 8; n = [0:1:N-1];
K = [0:1:N-1]; nk=n'*k;
WN = exp(-j*2*pi/N);
WNnk = WN.^nk;
Xk = x*WNnk
mag_Xk = abs(Xk);
phase_Xk = angle(Xk);
phase_degrees = rad2deg(phase_Xk);

figure;
subplot(2,1,1)
stem(n,mag_Xk,'filled','r','LineWidth',1.5)
xlabel('Index(K)'),ylabel('|X(k)|'),title('Magnitude Plot'),grid;

subplot(2,1,2)
stem(n,phase_degrees,'filled','b','LineWidth',1.5)
xlabel('Index(K)'),ylabel('X(k)'),title('Phase Plot'),grid;

B=conj(WNnk);
Xk_inv=Xk.';
Xn=(1/N)*(Xk)*B
figure;
stem(n,Xn,'filled','k','LineWidth',1.5)
xlabel('Index(n)'),ylabel('x(n)'),title('Signal in time domain x(n)'),grid;
KINZA PERVEZ
EE-20141
LAB SESSION 5

TASK#2:

Inverse DFT using Matrix inversion.


Develop a MATLAB code to find the inverse DFT output of the following frequency domain
sequence by using the iDFT equation in matrix form (use matrix inversion).

𝑋(𝑘)= {0, 4∠−90 ∘, 2∠45 ∘, 0 , 0, 0, 2∠−45 ∘ , 4∠90 ∘}


close all,clear all;clc;

Xk = [0,-4i ,1.414+1.414i, 0 , 0, 0, 1.414-1.414i ,4i];


N = 8; n = [0:1:N-1];
k = [0:1:N-1];
WN = exp(-j*2*pi/N);
nk = n'*k;
WNnk = WN.^nk;
B = inv(WNnk);
Xk_inv = Xk.';
Xn = (1/N)*(Xk)*B

figure;
stem(n,Xn,'filled','r','LineWidth',2)
xlabel('Index(n)'),ylabel('x(n)'),title('Signal in time domain x(n)'),grid;

TASK#3:

Inverse DFT using the Conjugate method.


Develop a MATLAB code to find the inverse DFT output of the following frequency domain
sequence by using the iDFT equation in matrix form (use conjugate method).

𝑋(𝑘)= {0, 4∠−90 ∘, 2∠45 ∘, 0 , 0, 0, 2∠−45 ∘ , 4∠90 ∘}


KINZA PERVEZ
EE-20141
LAB SESSION 5

close all,clear all;clc;

Xk = [0, -4i, 1.414+1.414i, 0, 0, 0, 1.414-1.414i, 4i];


N = 8; n = [0:1:N-1];
k = [0:1:N-1];
WN = exp(-j*2*pi/N);
nk = n'*k;
WNnk = WN.^nk;
B = conj(WNnk);
Xk_inv = Xk.';
Xn = (1/N)*(Xk)*B

figure;
stem(n,Xn,'filled','b','LineWidth',1.5)
xlabel('Index(n)'),ylabel('x(n)'),title('Signal in time domain x(n)'),grid;

You might also like