Difference 'bandpower' with time-dependent signal or 'bandpower' with PSD
4 views (last 30 days)
Show older comments
Inti Vanmechelen
on 13 Jul 2020
Commented: Inti Vanmechelen
on 13 Jul 2020
Hi all,
I have a question with respect to matlab's built-in function "bandpower".
The power of a certain signal can be calculated starting from a time-dependent signal, or from a PSD outcome.
In both cases, the result is the same:
t = 0:0.001:1-0.001;
fs = 1000;
x = cos(2*pi*100*t)+randn(size(t));
p = bandpower(x)
p = 1.4368
[pxx,f] = periodogram(x,rectwin(length(x)),length(x),fs);
p2 = bandpower(pxx,f,'psd')
p2 = 1.4368
However, when adding a frequency range (since I am interested in the average power in a specific frequency range), the result is not the same with the two methods:
freqrange = [0,5];
p = bandpower(x,fs,freqrange)
p = 0.0122
[pxx,f] = periodogram(x,rectwin(length(x)),length(x),fs);
p2 = bandpower(pxx,f,freqrange,'psd')
p2 = 0.0136
Any suggestion as to why these results are not equal would be greatly appreciated!
0 Comments
Accepted Answer
Deepak Gupta
on 13 Jul 2020
Hi Inti,
Bandpower function by default uses hamming window and in the psd calculation you have used rectangular window which is creating the difference in two methods so if you use same windows in both methods, results should be same.
t = 0:0.001:1-0.001;
fs = 1000;
x = cos(2*pi*100*t)+randn(size(t));
freqrange = [0,5];
p1 = bandpower(x,fs,freqrange)
[pxx,f] = periodogram(x,hamming(length(x)),length(x),fs);
p2 = bandpower(pxx,f,freqrange,'psd')
Cheers,
Deepak
More Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!