Lab Report 05
Lab Report 05
Submitted by:
ID: 181016018
Submitted to:
end
X_mag = abs(X);
subplot(512);
stem(X_mag);
% FFT
X2 = fft(x);
X_fft = abs(fft(X2));
subplot(513);
stem(X_fft);
%IFFT
x_ifft = ifft(X2);
X_ifft = ifft(X2);
subplot(514);
stem(x_ifft);
%DFT
N=4;
x=[2 3 -1 4];
t=0:N-1;
subplot(311);
stem(t,x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Input sequence')
subplot(312);
stem(0:N-1,abs(fft(x)));
xlabel('Frequency');
ylabel('|X(k)|');
title('Magnitude Response');
subplot(313);
stem(0:N-1,angle(fft(x)));
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
Results:
Answer to the question no: 02
For 32:
clear all;
close all;
clc;
N = 32;
n = 0: (N-1);
x = 2*sin(2*pi*(5/16)*n) + 5*sin(2*pi*(5/8)*n);
subplot(511);
stem(x);
for k = 0: N-1 m = k + 1;
expo_term = exp(-j*2*pi*k*n / N); mult_term = x.*expo_term;
X(m) = sum(mult_term);
end
For 128
clear all;
close all;
clc;
N = 128;
n = 0: (N-1);
x = 2*sin(2*pi*(5/16)*n) + 5*sin(2*pi*(5/8)*n);
subplot(511);
stem(x);
for k = 0: N-1 m = k + 1;
expo_term = exp(-j*2*pi*k*n / N); mult_term = x.*expo_term;
X(m) = sum(mult_term);
end
Results:
Pic: for 32
Pic: for 128
For both:
clear all;
close all;
clc;
N = 32;
n = 0: (N-1);
x = 2*sin(2*pi*(5/16)*n) + 5*sin(2*pi*(5/8)*n);
subplot(511);
stem(x);
for k = 0: N-1 m = k + 1;
expo_term = exp(-j*2*pi*k*n / N); mult_term = x.*expo_term;
X(m) = sum(mult_term);
end
% for 128
N = 128;
n = 0: (N-1);
x = 2*sin(2*pi*(5/16)*n) + 5*sin(2*pi*(5/8)*n);
subplot(512);
stem(x);
for k = 0: N-1 m = k + 1;
expo_term = exp(-j*2*pi*k*n / N); mult_term = x.*expo_term;
X(m) = sum(mult_term);
end
Pic: For both 32 and 128
Discussion: In our experiment we learn how to plot the dft and we can calculate the any point and also measuring
the ifft and fft and also plot them. We also repeat the value for the 32 and 128 and find the accurate results.