What I have:
A digital signal sampled at Fs
composed of a QPSK modulation at Fmod
plus some additive white gaussian noise.
What I want:
$$ modPower/signalPower $$
The idea behind is that I want to detect if there is a communication at Fmod on the channel or if there's just noise.
What I do:
Over the observation window n
I compute:
$$signalPower = \sum\limits_{i=1}^n s(i)^2$$
$$modPowerCos= \sum\limits_{i=1}^n s(i)*cos(2\pi*Fmod*i/Fs)$$
$$modPowerSin= \sum\limits_{i=1}^n s(i)*sin(2\pi*Fmod*i/Fs)$$
$$modPower = modPowerCos^2 + modPowerSin^2$$
$$ratio = modPower / signalPower$$
My code:
% Ns = Number of samples per symbol
% Nsyn = Number of symbols of the window
% Nt = Length of the window
% Fmod = Modulation Frequency
% Fs = Sampling Frequency
Nt = Nsym*Ns;
signalPower = zeros(1, length(obj.signal)); % Signal Powe
modPowerCos = zeros(1, length(obj.signal)); % Fmod cos correlation
modPowerSin = zeros(1, length(obj.signal)); % Fmod sin correlation
for ii = obj.Ns:length(obj.signal)
for jj = 0:Nt-1
if ii-jj > 0 && ii-jj <= length(obj.IQrx)
signalPower(ii) = signalPower(ii) + ...
obj.signal(ii-jj)^2;
modPowerCos(ii) = modPowerCos(ii) + ...
obj.signal(ii-jj) * ...
cos(2*pi*Fmod*(ii-jj)/Fs);
modPowerSin(ii) = modPowerSin(ii) + ...
obj.signal(ii-jj) * ...
sin(2*pi*Fmod*(ii-jj)/Fs);
end
end
modPowerCos(ii) = abs(modPowerCos(ii));
modPowerSin(ii) = abs(modPowerSin(ii));
end
My problem:
I find a ratio higher than 1
and I think it comes from a wrong formula but I don't know which one.
Example:
In the picture bellow in blue is the computed signal power signalPower
while in magenta is the computed Fmod power modPowerCos + modPowerSin
. You can see that modPower
is higher than signalPower
, which bugs me.