How does bandpower() round the input frequencies in variable 'freqrange'?

1 view (last 30 days)
I am reviewing the documentation on the function 'bandpower' (Band power - MATLAB bandpower (mathworks.com))
My question is about the input variable 'freqrange':
If I want the range [4, 8), i.e. I want the power at 4 Hz and up to but not including 8 Hz, how would I communicate that to the bandpower function? I'm guessing that bandpower is based on FFT analysis, which would give signal power at discrete frequency bins and frequency resolution depends on signal length.
So if I told bandpower that freqrange=[4 7.99], would it round up to 8? or would it round down to the nearest frequency bin? (e.g. down to 7.75 if frequency resolution is .25Hz)

Accepted Answer

Paul
Paul on 31 Mar 2023
Edited: Paul on 31 Mar 2023
Hi Joey,
bandpower is an .m file, at least in 2022a, so you can inspect the code.
My reading is that it will compute the power from f1 to f2 where f1 is the largest periodogram frequency that satisfies f1 <= freqrange(1) and f2 is the smallest frequency that satisfies f2 >= freqrange(2).
rng(100)
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
The frequency spacing is
1000/numel(t) % Hz
ans = 1
Bandpower from the exact frequencies from 50-150
pband1 = bandpower(x,1000,[50 150])
pband1 = 0.6190
Bandpower still from 50-150 because those are the closest that bound freqrange from below and above at spacing of 1 Hz
pband2 = bandpower(x,1000,[50.9 149.1])
pband2 = 0.6190
isequal(pband1,pband2)
ans = logical
1

More Answers (0)

Categories

Find more on Measurements and Feature Extraction in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!