Reputation: 53
I need to calulate the distance of all points stored in an array which size is <17642065x2 double> with the all points of other array which size is <273839x2 double>. The points stored in both array are in form of:
A = 341 45 456 32 987 10 4003 332 ... ... ... ... .... ....
B = 344 67 786 90 1234 47 3456 222 ... ... ... ... .... ....
I have to calculate distance for all points. For example the algorithm calculates the distnace between (341,45) and (344,67), then (341,45) and (780,90), then (341,45) and (1234,47), then (341,45) and (3456,222) then (456 32) and (344,67) and so on. Your help will be greatly appreciated
Upvotes: 2
Views: 142
Reputation: 25
I think the answer of matheburg on this question(
Efficiently compute pairwise squared Euclidean distance in Matlab) answers your question. It is even faster than pdist2
, which can be useful when you have to do this computation on multiple arrays.
Upvotes: 1
Reputation: 9655
You can use Matlab's builtin pdist2
function:
d = pdist2(A,B);
Upvotes: 3