tags:

views:

32

answers:

2

I am trying to classify some data based on euclidean distances in matlab the only problem is that matlab is giving me numbers that look like these as distances

0 + 4.9713i
0 + 7.8858i

 num1<num2  
 num2<num1 

both return 0. how is this possible?

+3  A: 

The numbers you're getting are imaginary numbers. You should never obtain imaginary numbers when you calculate Euclidean distances.

Check that your Euclidean distances are correct, such as

distance=sqrt(deltaX.^2 + deltaY.^2)

If you're really sure that your distances should be complex numbers, make the comparison using e.g. the norm, i.e.

norm(num2) > norm(num1)

This evaluates to true for me.

Jonas
A: 

Numbers with real and imaginary parts are not orderable. Maybe you mean order by distance from origin?

MatlabDoug

related questions