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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
truefor me.