finding dft without using fft
Mostrar comentarios más antiguos
Hi Guys!
I have one file name as data2 which has 100000 velocity data in column2 and I want to divide this data into record size of 256 and then perform dft without using the built in fft function in matlab. I also want to take a vaerage of these dft results point for point for all the dft results. I have perform the fft for the same data and i am expecting almost same types of plot for fft and dft. I have written a code for this but the plot that i am geeting is not similar to fft. Can you please help me what i am missing in my code. Here is my script
fontSize = 10;
tic;
start1= 1;
last1= 256;
for n= 1:1:390
e(start1:last1,1)= data2(start1:last1, 2);
start1= last1+1;
last1= start1+ 255;
end
l=length(e)
dummymat1= zeros(l,1);
for v= 0:l-1
for n= 0:l-1
dummymat1(v+1)= dummymat1(v+1)+ e(n+1)* exp(((-i)*2*pi*v*n)/l);
end
end
dft_1= abs(dummymat1);
first_point= 1;
last_point= 256;
for n= 1:1:390
f(:,n)= dft_1(first_point:last_point, 2);
first_point= last_point+1;
last_point= start1 + 255;
end
for z=1:1:256
sum (z,:) = f(z,:);
end;
for x=1:1:129
avg(x,:)= mean(sum(x,:));
end
xx= linspace(0,15000/2,129)
loglog(xx,avg);
xlim([10^1 10^4])
xticks([10^1 10^2 10^3 10^4])
xticklabels({'10^1', '10^2', '10^3','10^4'})
ylim([10^1 10^5])
yticks([10^1 10^2 10^3 10^4 10^5])
yticklabels({'10^1', '10^2', '10^3', '10^4','10^5'})
toc;
5 comentarios
Raushan
el 21 de Sept. de 2022
Raushan
el 21 de Sept. de 2022
Walter Roberson
el 21 de Sept. de 2022
A lot of people have posted code to "manually" do fourier transform, and I am sure that there are File Exchange contributions to do it as well. It isn't worth our time to debug this particular one.
Raushan
el 21 de Sept. de 2022
Walter Roberson
el 21 de Sept. de 2022
dft means "discrete fourier transform". fft means "fast fourier transform", which is a particular algorithm for calculating a dft efficiently. If you "did fft" then you did dft -- all fft are dft .
But your fourier transform algorithm does not analyze the length of the signal down to prime factors, and it does not implement a butterfly transform. It is not, in fact, a fast fourier transform, just a discrete fourier transform. fft is a dft implemented with mathematical short-cuts
There is also the term stft which is "short time fourier transform". It consists of "sliding" a window over the data, taking a windowing function to reduce sharp edges at the ends, and doing a dft (discrete fourier transform) on the resulting window -- most commonly by calling fft() to implement the discrete fourier transform. You do not appear to be doing that.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
