bandpower, why doesn't percentage power add up?

4 次查看(过去 30 天)
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!?

采纳的回答

Greg Dionne
Greg Dionne 2015-10-22
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by