Untitled Note
By: Anonymous11/15/20225 views Public Note
clc;
close all;
clear all;
N = 32;
x = [1 1 1 1 1 zeros(1,27)];
X = zeros(1, N);
W = exp(-1j*2*pi/N);
for k = 1:N
temp = 0;
for n = 1:N
temp = temp x(n)*(W^((k-1)*(n-1)));
end
X(k) = temp;
end
subplot(3,1,1)
stem((0:N-1)/N, abs(X))
grid;
title("DFTdirect")
xlabel('freq');
ylabel('|Homg');
xf=fft(x);
y= sum(x.*x);
z=round(sum(abs(xf).^2/32));
subplot(3,1,2)
title('praseval verification')
stem(z);
X1 = abs(fft(x,N));
X1=fftshift(X1);
F = [0:N-1]/N;
subplot(3,1,3)
plot(F,X1),title('mag'),axis([0 1 0 16])