how to use FFT in matlab using imported data in time domain excel file
Mostrar comentarios más antiguos
i have some polymers characterized by transmission terahertz time domain spectroscopy (THz-TDS).
1 comentario
Gagan Jain
el 17 de Dic. de 2021
Can you please tell where did you extract that data from? I’m doing a similar project
Respuesta aceptada
Más respuestas (2)
Wayne King
el 12 de Ag. de 2012
Editada: Wayne King
el 12 de Ag. de 2012
There is a slight variation depending on whether you have an even or odd number of samples in your data.
Even length:
xdft = fft(X(:,2));
% sampling interval -- assuming equal sampling
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
xdft = xdft(1:length(xdft)/2+1);
plot(freq,abs(xdft))
Odd length
xdft = fft(X(:,2));
% sampling interval -- assuming equal sampling
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
xdft = xdft(1:round(length(x)/2));
plot(freq,abs(xdft))
4 comentarios
Ryzx7
el 21 de En. de 2016
xdft = xdft(1:round(length(x)/2));
For that line the x needs to be an X right?
Walter Roberson
el 21 de En. de 2016
Yes.
It looks to me as if the versions could be merged by using
xdft = xdft(1:ceil(length(X)/2));
Mathias
el 25 de Feb. de 2017
This doesn't seem to work for me. But why not just use the length of freq?
xdft = xdft(1:length(freq));
Sahaphol Hamanee
el 14 de Feb. de 2018
Editada: Sahaphol Hamanee
el 14 de Feb. de 2018
Hi Wayne King, thank you for your guidance. May I ask what DF = Fs/size(X,1); is for? What is the meaning of it? It is the only thing I didn´t understand.
Best Regards
Wayne King
el 13 de Ag. de 2012
Editada: Wayne King
el 13 de Ag. de 2012
To get the phase, use angle()
phi = angle(xdft);
To export the frequencies and magnitudes back to Excel, place them in a matrix.
Xdftmatrix = [freq' abs(xdft)];
then use xlswrite
1 comentario
Wayne King
el 13 de Ag. de 2012
Editada: Wayne King
el 13 de Ag. de 2012
phi = angle(xdft);
plot(freq,phi)
You want to plot the phase as a function of frequency
Categorías
Más información sobre Programming 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!