I have the following final code. I have 12 data sets. Hower FFT is performed for 14 data sets. I printed the FFT output data. Why the two data sets have no imaginary values? Are these zero values? It looks to be something like FFT is performed on some regular number of data sets. Also I was wondering how to draw an average curve line (by curve fitting ) on the fourier spectrum plot.
Thanks, - okd
The Following is the Final MATLAB Codes.
Reading File
---------------
» data1=dlmread('C:\Document
s and Settings\DDR\My Documents\Ltest.txt','\t')
;
Incrementing by 0.02 to generate time data
--------------------------
----------
----------
-----
» dstart = 0.02;
» dstep = 0.02;
» n = length(data1);
» dend = dstart+dstep*(n-1);
» data2 = (dstart:dstep:dend)'; % ' is for transpose
» data = [data1 data2]; % add data2 as a second column to data1
Integration
-------------
» intvalue=cumtrapz(data2, data1);
» plot(data2, intvalue);
Fourier Transform
----------------------
» NFFT=2^nextpow2(n);
» Y=fft(data1,NFFT)/n
Y =
1.3545
-2.0474 + 0.7045i
1.2596 + 0.1405i
-0.1336 - 1.0734i
-1.5277 + 0.8807i
0.9026 + 0.0748i
-0.3674 - 0.3528i
-0.5716 + 0.4137i
0.6073
-0.5716 - 0.4137i
-0.3674 + 0.3528i
0.9026 - 0.0748i
-1.5277 - 0.8807i
-0.1336 + 1.0734i
1.2596 - 0.1405i
-2.0474 - 0.7045i
» f=(50/2*linspace(0,1,NFFT/
2+1))';
» plot(f,2*abs(Y(1:NFFT/2+1)
));
»