How to calculate distance between 2 complex points?
31 views (last 30 days)
Show older comments
Hi,
After modulating random data with QPSK, I obtained a matrix of complex numbers:
Signal_1 = 1.00 - 1.00i, -1.00 - 1.00i, -1.00 + 1.00i, -1.00 + 1.00i, -1.00 - 1.00i, 1.00 + 1.00i
After adding some noise to this complex matrix, it changed to something like this:
Signal_2 = 0.960 - 0.92i, -0.90 - 1.05i, -1.15 + 1.06i, -0.91 + 1.07i, -1.08 - 1.01i, 1.03 + 0.98i
By using scatterplot we can clearly see that each of the original points from Signal_1 was displaced, resulting in Signal_2.
Is there a way to implement a FOR loop to calculate the distance between the points of the 2 matrices?
I.e. distance(i) = distance between points Signal_1(i) and Signal_2(i), for i=1:length(Signal_1)
The purpose of calculating the distance is to know by how much the points moved due to the noise insertion.
It would be ideal to obtain a new matrix containing the distance of all the points of Signal_2 with respect to the points of Signal_1.
Bear in mind that each of the values of the 2 signals are complex numbers.
Thanks.
2 Comments
Walter Roberson
on 21 Sep 2013
An important question here would be whether "movement" should be measured in Euclidean distance. My instinct is that ideally it should not be -- but it could be that Euclidean is a "good enough" approximation for your purposes.
Answers (2)
Roger Stafford
on 21 Sep 2013
The reference to "phase" in your diagram would seem to imply that the 'Q' and 'I' quantities refer to the real and imaginary parts of your signals. If so, the function you need is 'abs' of the vector difference between the signals at each point. This would be the length Of "error vector" in your diagram.
2 Comments
Roger Stafford
on 22 Sep 2013
Just ordinary subtraction in matlab:
Signal_1-Signal_2
I am assuming that Signal_1 and Signal_2 play the roles of "MEASURED SIGNAL" and "IDEAL SIGNAL" in your diagram and that you are trying to find the length of the "Error Vector", and that Q and I are the real and imaginary parts thereof.
Youssef Khmou
on 23 Sep 2013
Jean luc, you can perform the task without using the pdist function, here is version :
S1=[1.00 - 1.00i, -1.00 - 1.00i, -1.00 + 1.00i, -1.00 + 1.00i, -1.00 - 1.00i, 1.00 + 1.00i];
S2=[0.960 - 0.92i, -0.90 - 1.05i, -1.15 + 1.06i, -0.91 + 1.07i, -1.08 - 1.01i, 1.03 + 0.98i];
figure, compass(S1), hold on, compass(S2,'r'), legend(' original','noisy');
% Computing the distance
N=length(S1);
D=0;
for n=1:N
D(n)=norm(S2(n))-norm(S1(n));
end
% PHASE converted to degrees
Phase=(phase(S2)-phase(S1))*180/pi;
0 Comments
See Also
Categories
Find more on QPSK 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!