How to use FFT on my data?
8 views (last 30 days)
Show older comments
Accepted Answer
Star Strider
on 20 Mar 2018
Other peaks may exist, although if the constant, (or ‘d-c’) offset is large enough, you will not be able to see them.
Try this:
id = data(:,2); % to load current values from the second column of my .txt
i = id - mean(id);
That should reveal the other peaks.
8 Comments
Star Strider
on 22 Mar 2018
Taking the absolute values first should not cause your data to plot upside down. Taking the absolute value is the correct way to calculate the spectrum and convert it to dB.
I described essentially this procedure in my earlier Comment:
Ia = abs(I);
Iref = max(Ia);
Inorm = 20*log10(Ia/Iref);
Note that decibels are defined with respect to the base 10 logarithm, not the natural logarithm. I corrected that in the code I posted here.
As for the scaling, you can certainly divide the dB values by 10 to get them to go from -100 to 0. However, this significantly distorts your amplitude information, and the units are no longer dB.
See if these changes improve your results.
More Answers (2)
Patrik Soukup
on 26 Mar 2018
1 Comment
Star Strider
on 26 Mar 2018
The ‘L’ parameter is the length of the Hann window, in units of samples. (The purpose of the window functions is to reduce the effects of using a finite sequence to represent an infinite sequence.)
I use windows to design filters, and do not generally use them to calculate Fourier transforms, because they significantly distort the transformed data. My signal processing references only discuss them in the context of filters.
As I read my references, ‘L’ should be the length of your signal. See for example hanning ,hamming window in matlab? (link).
Patrik Soukup
on 5 Apr 2018
3 Comments
Star Strider
on 6 Apr 2018
The default line width is 0.5 points. It may be that it is not possible to define a line width less than that. I cannot find that specific information in the documentation, so I do not know for sure.
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

