MATLAB: Can I get pdist2 results as only one value

images similaritypdist2

Hi,
I've been using some code I wrote to calculate some distances (Euclidean, Canberra, etc). However, I did some research and I found out that using pdist2 function I could get those distances in an easier way. The problem is that pdist2 returns to me a matrix of distances, and not only one value as my code does. Is it possible to get only one value as a distance result using pdist2 function or another Matlab function? I also tried Jeffrey's distance code I found in file exchange, but I get the same (matrix of results).
Thank you in advance for your help.

Best Answer

pdist2 gets the distances between every possible pair of points. What do you have? Just two points? If so, use hypot() or sqrt(). If you have multiple points then explain how you would like to get just one distance when there are really N*(N-1) distances.