필터 지우기
필터 지우기

Area of a Spectrum

조회 수: 30 (최근 30일)
Lisa Justin
Lisa Justin 2012년 8월 1일
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.

채택된 답변

Dr. Seis
Dr. Seis 2012년 8월 1일
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
Dr. Seis
Dr. Seis 2012년 8월 1일
편집: Dr. Seis 2012년 8월 1일
Yeah... in your case, you would just need:
area_y = sum(abs(y))/N;
The frequency increment ( df ) comes into play only if you scaled your FFT amplitudes ( y ) by the time increment ( dt ) - since dt*df = 1/ N. If you do not scale your FFT amplitudes inside your srs function, then you should just divide your sum by N to get the area. If you want to find the area between a frequency range, you will have to do something a little different. See below:
Example:
N = 4096;
fs = 2000;
x = randn(1,N);
df = fs/N;
Nyq = fs/2;
y = fft(x);
f = ifftshift(-Nyq : df : Nyq-df);
If your y represents both the negative and positive frequency amplitudes:
area_y_10_800 = sum(abs(y( abs(f) >= 10 & abs(f) <= 800 )))/N;
or if your y represents only the positive frequencies
area_y_10_800 = 2*sum(abs(y( f >= 10 & f <= 800 )))/N;
However, you do not want to double the amount if you are including either your 0 frequency or Nyquist frequency amplitude in the frequency range.
Lisa Justin
Lisa Justin 2012년 8월 2일
Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wayne King
Wayne King 2012년 8월 1일
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
Lisa Justin
Lisa Justin 2012년 8월 1일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by