You are on page 1of 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