Discrete Fourier Transform MATLAB Code

3 Ansichten (letzte 30 Tage)
Sanaz Da
Sanaz Da am 8 Nov. 2020
This code computes the DFT from time domain.
Can anybody see the code below and help me to get the right answer?
my problem is:
when I change N value, for example, to 4, 5, 10 ,or other values.
X(1) changes with that. but I think X(1) must be the same for every value of N.
just like the shape below: the N value changes but the vertical value is the same.
I appreciat if you help me.
Thank you.
clear; clc;
% %% Analytical
N=4;
k=0:N-1;
X=zeros(N,1);
t=k/N;
%x=5+2*cos(2*pi*t-pi/2)+3*cos(4*pi*t)
x=abs((1-(0.012.*(pi.*52.*(t-0.3721)).^2)).*exp(-(pi.*52.*(t-0.3721).^2)))
sum(x)/N
for k=0:N-1
for n=0:N-1
X(k+1)=X(k+1)+x(n+1)*-i^(n*k)/N;
end
end
k1=[0:N-1];
stem(k1,abs(X))
% xlim([0 1])
% ylim([-1 1])

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by