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 allclear 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?
Best Answer