Area of a Spectrum

27 views (last 30 days)
Lisa Justin
Lisa Justin on 1 Aug 2012
What matlab command can give me the area of a spectrum. I have shock response spectrum but i need to find the area under the curve.

Accepted Answer

Dr. Seis
Dr. Seis on 1 Aug 2012
The area under your curve should just be:
N = numel(x);
dt = 1/fs;
df = fs/N;
y = fft(x)*dt;
area_y = sum(abs(y))*df; % which is also equal to: sum(abs(fft(x)))/N
energy_y = sum(abs(y).^2)*df;
If you really want "energy", then energy_y should be equal to energy_x:
energy_x = sum(x.^2)*dt;
  4 Comments
Lisa Justin
Lisa Justin on 2 Aug 2012
Thanks.

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 1 Aug 2012
Hi Lisa, If you have the Signal Processing Toolbox, you can use the avgpower() method of a spectrum object.
For example:
Fs = 1000;
t = 0:1/Fs:1-(1/Fs);
x = cos(2*pi*50*t)+sin(2*pi*100*t)+randn(size(t));
psdest = psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(x));
avgpower(psdest,[25 75])
The final line above integrates under the PSD from 25 to 75 Hz.
Note you can get the fraction of the total power in the specified interval with:
avgpower(psdest,[25 75])/avgpower(psdest)
  1 Comment
Lisa Justin
Lisa Justin on 1 Aug 2012
Thanks Wayne. But it is like this: I calculated the shock response spectrum Y and plotted between frequencies 10-500. I need the peaks and the area under the curve max(Y) gives me the peak and i tried area(Y) and i get a shaded plot again but what i really want is the value of the area of Y.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by