How to calculate distance between 2 complex points?
显示 更早的评论
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 个评论
Walter Roberson
2013-9-21
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.
Jean-luc
2013-9-21
回答(2 个)
Roger Stafford
2013-9-21
0 个投票
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 个评论
Jean-luc
2013-9-22
Roger Stafford
2013-9-22
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
2013-9-23
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;
类别
在 帮助中心 和 File Exchange 中查找有关 Signal Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
