Octave Band Averages from PSD

14 views (last 30 days)
John
John on 6 Oct 2012
Hi everyone,
I am using a simple code to extract the PSD from a set of time-based sound data. I am now interested in obtaining the octave band averages of this data and I am completely lost. Can anyone help me out?
The code I ave at the moment is:
*clear all
close all
echo on
Fs= 4000; % Sampling Frequency (Hz)
x = xlsread('No Excitation.csv',1,'J35:J52034');
Hs=spectrum.welch;
psd(Hs,x,'Fs',Fs);
echo off;*
Thanks, John

Answers (1)

Wayne King
Wayne King on 6 Oct 2012
Edited: Wayne King on 6 Oct 2012
You want to average the power over octave bands? You can do that with the avgpower() method.
t = 0:0.001:1-0.001
Fs = 1000;
x = cos(2*pi*50*t)+1/2*sin(2*pi*200*t)+randn(size(t));
psdest = psd(spectrum.welch,x,'Fs',Fs);
Now to get the average power from [0,100] Hz
pwr = avgpower(psdest,[0 100]);
It may be more useful to consider the percentage of the total power in that interval
totpower = avgpower(psdest,[0 Fs/2]);
100*(pwr/totpower)
  1 Comment
John
John on 8 Oct 2012
Thankyou. That is extremely useful. I do have one more question though if you don't mind.
I am using msspectrum to plot the sound power over the frequency range and using avgpower on my calibration tests to determine how much each test needs to be adjusted.
ie. adjustment = real calibration value - avgpower(calibration)
At this stage, how do I take that adjustment value and apply it to my tests.
ie. instead of plotting by hmss = msspectrum(Hs,x,'Fs',Fs);
plot(hmss)
I want to plot that exact plot by translated down by the adjustment value.
Also, is there any way of exporting the (x,y) values that build the graph if i do plot(hmss)?

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!