I have to analyse a signal which has been modulated with a QPSK using matlab and I can't seem to get things right.
What I have: a complex signal sampled at a known frequency.
What I want: the power ratio of a certain frequency. So if the signal is of the form a*cos(wt)+a*cos(2wt)
then I should get 0.5 for w
and 0.5 for 2w
.
I don't know where is the problem with my code but I get a frequency power higher than the signal power as you can see it in the graph bellow (in blue: signalPower
, in red: Fm
).
And here is my code:
% Nsym : Number of symbol used for the detection
% Ns : Number ofsamples per symbol
% IQrx : Complex signal to analyse
% Fmod : Modulation frequency
Nt = Nsym*Ns;
signalPower = zeros(1, length(IQrx));
Fp = zeros(1, length(IQrx));
Fm = zeros(1, length(IQrx));
for ii = 1:length(IQrx)
for jj = 0:Nt-1
if ii-jj > 0 && ii-jj <= length(IQrx)
signalPower(ii) = signalPower(ii) + ...
abs(IQrx(ii-jj))^2;
Fp(ii) = Fp(ii) + ...
IQrx(ii-jj) * ...
exp(1i*2*pi*Fmod*(ii-jj)/obj.Fs);
Fm(ii) = Fm(ii) + ...
IQrx(ii-jj) * ...
exp(-1i*2*pi*Fmod*(ii-jj)/obj.Fs);
end
end
Fp(ii) = abs(Fp(ii))^2;
Fm(ii) = abs(Fm(ii))^2;
end
Edit: As requested in the comments the formulas that I use are: Consider that i goes in the time window of interest.
signalPower = sum ( signal(i)^2 )
Fp = abs( sum( signal * exp(1i*2*piFmod(i)/obj.Fs) ) )^2
Fp = abs( sum( signal * exp(-1i*2*piFmod(i)/obj.Fs) ) )^2
Seems to me that
signalPower(ii) = signalPower(ii) + abs(IQrx(ii-jj))^2;
Should be something more like:
signalPower(ii) = signalPower(ii) + abs(IQrx(ii-jj));
You might want to try something a bit simpler for the signal power like:
pwt=x'*x; % Power in time domain
where x
is your windowed time series value. (inspiration from this link).