Bandpower function question/problem

8 views (last 30 days)
I am trying to use the Matlab bandpower function to measure power from noise sources. I originally did my own function but would prefer to use a function from Matlab. I have a problem with the results when I pass any additional inputs into the function to use the frequency space option.
I have included my code below, and hopefully as you look at the code you will understand what I am doing and my question.
_ %%CODE Starts below _
%Clear the workspace
close all
clear all
%Set the clock at 100MHz
fs=100E6;
period = 1/fs;
%Create 1ms time axis based on 100MHz clk
t=period:period:1E-3;
%Create random frequency for noise
f = rand(1,length(t))-.5;
sig1 = cos(2*pi*f.*t);
sig2 = sin(2*pi*f.*t);
%Subtract the median value to remove the DC bias
sig1 = sig1 - median(sig1);
sig2 = sig2 - median(sig2);
%Make it complex
sig1 = complex(sig1,sig2);
N = length(sig1);
fullPower = bandpower(sig1);
%Sig1 is even length and complex
fullPower2 = bandpower(sig1,fs,[-(N-2)*fs/(2*N), fs/2] );
%%End of code
I think the variables fullPower and fullPower2 should have the same results because I feel I am including the entire frequency spectrum in both functions. Unfortunately they are not the same. What am I missing?

Accepted Answer

Honglei Chen
Honglei Chen on 13 Jun 2014
The calculation of the fullPower is simply the square of the signal's rms value. As to the fullPower2, the command line help indicates that it is computed using periodogram with a Hamming window. That's why they are slightly different.
HTH
  1 Comment
Paramonte
Paramonte on 13 Jul 2015
and why is fullPower2 higher than fullPower.Should be the other way round since bandpower(sig1,fs,[-(N-2)*fs/(2*N), fs/2] ) is suposed to use a window over the signal which effectively decreases its power

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!