bandpower, why doesn't percentage power add up?

3 vues (au cours des 30 derniers jours)
CarrotCakeIsYum
CarrotCakeIsYum le 19 Oct 2015
Commenté : CarrotCakeIsYum le 26 Oct 2016
I'm measuring the frequency people sway at whilst they balance. I need to calculate the percentage power of specific frequency bands. The input vector is sampled at 1000Hz, and has a length of 15000.
To do this I've been using the Matlab function 'bandpower', and have written the following function:
function output = balance_power_test(data)
%Calculates the power of frequencies in four frequency bands.
%Output is given as percentage of total power.
output = zeros(4,1);
ptot = bandpower(data,1000,[0 500]);
pwr_band1 = bandpower(data,1000,[0 50]);
pwr_band2 = bandpower(data,1000,[50 100]);
pwr_band3 = bandpower(data,1000,[100 200]);
pwr_band4 = bandpower(data,1000,[200 500]);
output(1) = 100*(pwr_band1/ptot);
output(2) = 100*(pwr_band2/ptot);
output(3) = 100*(pwr_band3/ptot);
output(4) = 100*(pwr_band4/ptot);
end
However I'm finding that the percentages of power don't add up to anywhere near 100%. E.g. testing the above:
rng('default')
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
>> balance_power_test(x)
ans =
0.0847
0.0847
0.0847
0.3879
The percentage powers add up to 64.19%. What am I doing wrong!?

Réponse acceptée

Greg Dionne
Greg Dionne le 22 Oct 2015
Looks like you're double-counting frequencies.
Try this instead:
function output = balance_power_test(data)
%Calculates the power of frequencies in four frequency bands.
%Output is given as percentage of total power.
output = zeros(4,1);
ptot = bandpower(data,1000,[0 500]);
pwr_band1 = bandpower(data,1000,[0 50]);
pwr_band2 = bandpower(data,1000,[51 100]);
pwr_band3 = bandpower(data,1000,[101 200]);
pwr_band4 = bandpower(data,1000,[201 500]);
output(1) = 100*(pwr_band1/ptot);
output(2) = 100*(pwr_band2/ptot);
output(3) = 100*(pwr_band3/ptot);
output(4) = 100*(pwr_band4/ptot);
end
  1 commentaire
CarrotCakeIsYum
CarrotCakeIsYum le 26 Oct 2016
Sorry to be very late... but thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by