0
votes

I am using pdist to calculate euclidian distances between three dimensional points (in Matlab). However i have some coordinates that i cannot remove from the matrix, but that i want pdist to ignore.

I have tried overwriting the values i want to ignore with NaN's, but pdist still uses them in the calculation. Is there a way to make pdist ignore a value in it's process?

1

1 Answers

0
votes

I don't know pdist, but it looks like you need to remove certain rows for it to work the way you want. If you were to find the indices of the rows you don't want, you could do the following:

d = [1,2,3;2,3,4;3,4,5]
d =
    1   2   3
    2   3   4
    4   5   6
i = [1 3]
d(i,:)
    1   2   3
    4   5   6
id = pdist(d(i,:)) % assume id=2
real_index = i(id) % now the real index is i(2)=3

Now you would have the index of the row in real_index. (pdist doesn't seem to exist in my matlab so I can't get the real output, but the idea is there!)