Area under FFT curve
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need to calculate the area under curve for the fundamental frequency and some harmonics in an FFT curve. I have attached the FFT curve.
For FFT I used below code:
Fs=125;
L=length(A(1250000:2500000));
n=pow2(nextpow2(L));
f=Fs*(0:1/n:1-(1/n));
df=log10(abs(fft(A(1250000:2500000).*hanning(L),n)));
I need to calculate the area under the curve for a certain bandwidth. For example, the fundamental frequency is 1.5 MHz and I need the area between 1.4 MHz and 1.6 MHz. I tried to use cumtrapz function using below code:
Int = cumtrapz(f,df);
Intv = @(a,b) max(Int(f<=b)) - min(Int(f>=a));
SegmentArea1 = Intv(1.5-.1, 1.5+.1)
SegmentArea2 = Intv(3-.1, 3+.1)
But it gives the same value for SegmentArea1 and SegmentArea2. I also tried to use trapz using:
trapz(df(find(abs(f-1.4)<0.0001):find(abs(f-1.6)<0.0001)))
but i got a negative value.
Am I using the correct functions or am I doing something wrong? Is there any other way to do it?
0 comentarios
Respuestas (1)
Star Strider
el 3 de Abr. de 2020
Calculate the areas of only the ‘positive frequencies’ half of the fft output, not the entire output. If the data are all positive (for example, the absolute value of the fft), negative values are usually because the independent variable (frequencies in an fft) are going from the Nyquist frequency to 0, rather than from 0 to the Nyquist frequency.
10 comentarios
Star Strider
el 5 de Abr. de 2020
My pleasure.
I doubt that there is any need to do a baseline correction of the fft output. If you want to remove the D-C offset (0 Hz peak) from the original time-domain signal (in order to see the other peaks more clearly), subtract the mean of the signal from the signal before doing the fft.
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!