Exp7 Watermark
Exp7 Watermark
Exp7 Watermark
AIM :-
Develop radix-2 butterfly FFT (Decimation in Time) algorithm for the computation of N-point
DFT.
THEORY:-
Symmetry: When the region between 0 and fs is examined, it can be seen that there is even
symmetry around the center point, 0.5fs, the Nyquist frequency. This symmetry adds
redundant information. Figure 1 shows the DFT (implemented with Matlab's FFT function) of a
cosine with a frequency one tenth the sampling frequency. Note that the data between 0.5fs
and fs is a mirror image of the data between 0 and 0.5fs
Write your own MATLAB function to compute DFT using FFT DIT, FFT DIF, FFT (in built
function)
%decimation in time
x = input('Enter the input sequence :');
l = length(x);
k = 0;
while((2^k)<1)
k = k+1;
end
x1 = [x zeros(1,(2^k)-1)];
n = length(x1);
y = zeros(1,n);
j = 1;
for k = 1:2:n;
xe(j) = x1(k);
j=j+1;
end
j = 1;
for k = 2:2:n;
xo(j) = x1(k);
j=j+1;
end
for k=1:1:n;
for j=1:1:(n/2);
y(k) = y(k) + xe(j)*exp(-4*pi*1i*(j-1)*(k-1)/n) + exp(-2*pi*1i*(k-1)/n)*xo(j)*exp(-
4*pi*1i*(j-1)*(k-1)/n);
end
end
axis tight
subplot(2,1,1)
stem(x)
xlabel("Samples [n]")
ylabel('Amplitude [n]')
title('input sequence x[n] 22102205')
subplot(2,1,2)
stem(abs(y))
xlabel("Freq index [k]")
ylabel('Magnitude |X[k]|')
title('DFT magnitude of x[n] 22102205')
%Decimation in frequency
X = input('Enter the input sequence :');
l = length(X);
k = 0;
while((2^k)<l)
k = k+1;
end
X11 = [X zeros(1,(2^k)-l)];
n = length(X11);
Y = zeros(1,n);
X1 = zeros(1,n/2);
X2 = zeros(1,n/2);
for j = 1:2:n
X1((j+1)/2) = X11(j);
end
for j = 2:2:n
X2(j/2) = X11(j);
end
for k = 1:n
for j = 1:n/2
Y(k) = Y(k) + (X1(j) + exp(-1i*pi*(k-1))*X2(j))*exp(-2i*pi*(j-1)*(k-1)/n); %
Corrected formula
end
end
subplot(2,1,1)
stem(X)
xlabel("Samples [n]")
ylabel('Amplitude [n]')
title('input sequence X[n] 22102205')
subplot(2,1,2)
stem(abs(Y))
xlabel("Freq index [k]")
ylabel('Magnitude |X[k]|')
title('DFT magnitude of X[n] 22102205')
OUTPUT:-
1.
2.
POSTLAB EXERCISE :-
Fs = 8000;
T = 1/Fs;
l = 240;
t = (0:l-1)*T;
x1 = 5*cos(2*pi*500*t);
x2 = 5*cos(2*pi*1200*t + 0.25*pi);
x3 = 5*cos(2*pi*1800*t + 0.5*pi);
x = x1 + x2 + x3;
subplot(4,1,1);
stem(t, x1);
title('x1(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,2);
stem(t, x2);
title('x2(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,3);
stem(t, x3);
title('x3(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,4);
stem(t, x);
title('x(t) ANKIT KESARI 22102205');
xlabel('Time (s)');
ylabel('Amplitude');
OUTPUT:-
Total sum of sinusoids: 3.6149e-13
LEARNING OUTCOME:-
Understanding the process of DFT using FFT DIT, FFT DIF, FFT (in built function).
Learning the code required to calculate the above