help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avgpower in Octave?


From: Dan F
Subject: avgpower in Octave?
Date: Wed, 18 Mar 2009 12:45:38 -0500

Folks,

Matlab 2007b (7.5.0) has an avgpower function. From
http://www.mathworks.com/products/signal/demos.html?file=/products/demos/shipping/signal/spectralanalysisobjsdemo.html:

"The avgpower method uses a rectangle approximation to the integral to
calculate the signal's average power using the PSD data stored in the
object.

"The avgpower method returns the average power of the signal which is
the area under the PSD curve."

Example invocation:

    numSamples = 10000
    frequency = 20
    amplitude = 10
    Fs = 1000
    t = [0:1/numSamples:1];
    sig = amplitude * sin(2*pi*frequency*t);
    h = spectrum.periodogram('rectangular');
    hopts = psdopts(h, signal);
    set(hopts,'Fs',Fs);
    p = psd(h,signal,hopts);
    lower = 12
    upper = 30
    beta_power = p.avgpower([lower upper]);

I am looking to replicate this sort of functionality in Octave. The
function "pwelch" seems like a possibility. To wit:

    ...
    sig = amplitude * sin(2*pi*frequency*t);
    pwelch('R12+');
    [spectra, freq]=pwelch(signal, [], [], [], Fs, plot_type='dB');

Now I *think* spectra has the y values of the PSD and freq has the x
values. So, I could find the samples in freq that fall between "lower"
and "upper" and .. er, average the corresponding values in spectra?
I'm pretty fuzzy on this.

Moreover, the values in "spectra" don't necessarily correspond to my
desired upper and lower, and I'm not sure what to do about that.

It might also be possible to get a single value from some sort of FFT
instead of using pwelch.

Any suggestions?

Thanks for your attention.

Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]