bandpower, why doesn't percentage power add up?

4 Ansichten (letzte 30 Tage)
CarrotCakeIsYum
CarrotCakeIsYum am 19 Okt. 2015
Kommentiert: CarrotCakeIsYum am 26 Okt. 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!?

Akzeptierte Antwort

Greg Dionne
Greg Dionne am 22 Okt. 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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by