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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.