MATLAB Answers

Calculate distance of one 5D point from all points of 5D matrix

6 views (last 30 days)
abaza
abaza on 24 Jul 2018
Commented: abaza on 24 Jul 2018
Dear All, could someone help me to calculate the distance between a 5 dimensional point from all 5 dimensional points of a matrix? Namely, I have a point A within a vector of size 1x5 and I would like to calculate 1000 distances between this point from a matrix 1000x5 (1000 points).
Thank you in advance

  0 Comments

Sign in to comment.

Accepted Answer

Ali Aghaeifar
Ali Aghaeifar on 24 Jul 2018
I think you are looking for pdist2
A = rand(1,5);
B = rand(1000,5);
C = pdist2(A, B);

  1 Comment

abaza
abaza on 24 Jul 2018
Thanks! I did not know that pdist2 works with different size vectors/matrices!

Sign in to comment.

More Answers (0)