FFT for an arbitrary plot using MATLAB
3 次查看(过去 30 天)
显示 更早的评论
Dear All, My question has not received much attention apparently. It might be too simple but I do not know how to use FFT tool implemented in MATLAB. Assume I have an arbitrary plot of the evolution of variable y in time. The plot obtained from the following data:
0 116.0080214
0.0005 116.051128
0.001 116.0939229
0.0015 116.1362197
0.002 116.1776665
0.0025 116.2178118
0.003 116.256182
.
.
.
.
50.0 123.000
The first and second columns represent time and the value of y at the corresponding t respectively. As it is clear in the data format time interval of the plot is from 0 to 50 ps. And I have data for the y component of the plot every 0.5 fs. Basically the plot contains 100000 data printed every 0.5fs. Using information of this page, I guess I have to choose the following values for my calculation:
Fs = 100000/50; % Sampling frequency (in 1/ps)
T = 1/Fs; % Sample time (in ps)
L = 100000; % Length of signal
t = (0:L-1)*T; % Time vector; my first column should replace this
% Also I know that the second column would be the y in the sample code used as an example in that page!
I do not know hoe I have to define X. I do appreciate any of your helps to illustrate it more for me! Best
0 个评论
采纳的回答
Walter Roberson
2015-6-24
In the notation of that page, you have x and y reversed. They use x to refer to the samples in time, and y to refer to the frequency information, whereas you are using y to refer to the samples in time. Using your notation, all that is needed is
result = fft(y(:,2));
and all the rest of what is there has to do either with generating data for use in the example, or has to do with labeling plots correctly.
5 个评论
Walter Roberson
2015-6-29
2^nextpow2(L) effectively "rounds up" to the next power of 2 from L. For example, the first power of 2 above 93 is 128 which is 2^7; nextpow2(93) would return 7 and 2^7 would give the 128. Likewise it would round 8191 up to 8192. But 2^nextpow2(L) is always the same as L if L is already a power of 2.
The reason for "rounding up" to the next power of 2 for FFT has to do with the performance of the Fast Fourier Transform, as FFT is fastest if the number of points is a power of 2. The original FFT algorithm only applied for exact powers of 2; extensions were later made to do prime decomposition of the length.
Basically on modern computers, the only reason to bother would be if you are doing millions of FFT of the same length, or if you are planning to do code generation for a DSP or FPGA. Just leave that part out for your purposes.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!