comparing between two arrays
Mostra commenti meno recenti
sorry if my question is trivial , but i'm still beginner and need your help. i have 3 points in the space say a , b, c each one is an array 2x3 , say a=[2 3 4 ; 9 8 7] ,b =[ 5 2 1 ; 6 3 2] , c=[ 4 7 1; 1 2 3]. i want to compare the distance between points a and b (dist12) with the distance between a and c (dist13), which is longer? thank you
5 Commenti
Azzi Abdelmalek
il 6 Ott 2013
A point in the space is represented by 1x3 array not 2x3
Mohammad Monfared
il 6 Ott 2013
Azzi is right. assuming a and b are two points in 3-D space ( each have 3 components), their euclidean distance is: norm(a-b).
mariam
il 7 Ott 2013
Jan
il 7 Ott 2013
@mariam: No, it is not clear enough. "Distance" is defined for single points only. Therefore it is not uniquely defined, what you are looking for.
mariam
il 8 Ott 2013
Risposte (2)
David Sanchez
il 7 Ott 2013
a=[2 3 4 ; 9 8 7];
b =[ 5 2 1 ; 6 3 2];
c=[ 4 7 1; 1 2 3];
dist_ab_cluster_1 = norm(b(1,:)-a(1,:));
dist_ab_cluster_2 = norm(b(2,:)-a(2,:));
dist_ac_cluster_1 = norm(c(1,:)-a(1,:));
dist_ac_cluster_2 = norm(c(2,:)-a(2,:));
dist_ab_cluster_1 =
4.3589
dist_ab_cluster_2 =
7.6811
dist_ac_cluster_1 =
5.3852
dist_ac_cluster_2 =
10.7703
1 Commento
mariam
il 7 Ott 2013
Andrei Bobrov
il 7 Ott 2013
a=[2 3 4 ; 9 8 7]; b =[ 5 2 1 ; 6 3 2]; c=[ 4 7 1; 1 2 3];
data = cat(3,a,b,c);
s = size(data);
t = reshape(data(:,:,nchoosek(1:s(3),2)') , s(1),s(2),2,[]);
out = squezze(sqrt(sum(diff(t,[],3).^2,2)));
3 Commenti
mariam
il 8 Ott 2013
Andrei Bobrov
il 8 Ott 2013
distance between a and b
mariam
il 9 Ott 2013
Categorie
Scopri di più su Random Number Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!