i want to find distances between coordinate points as i explained below?? any help??

1 vue (au cours des 30 derniers jours)
i have coordinates as
A = (0,0); B = (1,0); C = (2,0)
D = (0,1); E = (1,1); F = (2,1)
G = (0,2); H = (1,2); I = (2,2)
i want to distance between A to D plus D to B and so on......
matrix 1 (2*3)
[(AtoD+DtoB) (AtoE+EtoB) (AtoF+FtoB)
(AtoG+GtoB) (AtoH+HtoB) (AtoI+ItoB)
matrix 2 (2*3)
[(AtoD+DtoC) (AtoE+EtoC) (AtoF+FtoC)
(AtoG+GtoC) (AtoH+HtoC) (AtoI+ItoC)
matrix 3 (2*3)
[(BtoD+DtoA) (BtoE+EtoA) (BtoF+FtoA)
(BtoG+GtoA) (BtoH+HtoA) (BtoI+ItoA) ]
matrix 4 (2*3)
[(BtoD+DtoC) (BtoE+EtoC) (BtoF+FtoC)
(BtoG+GtoC) (BtoH+HtoC) (BtoI+ItoC) ]
matrix 5 (2*3)
[(CtoD+DtoA) (CtoE+EtoA) (CtoF+FtoA)
(CtoG+GtoA) (CtoH+HtoA) (CtoI+ItoA) ]
matrix 6 (2*3)
[(CtoD+DtoB) (CtoE+EtoB) (CtoF+FtoB)
(CtoG+GtoB) (CtoH+HtoB) (CtoI+ItoB) ]
finally i want six matrices as i explained above
thank you
  6 commentaires
darova
darova le 8 Août 2019
matrix 1 == matrix 3
matrix 2 == matrix 5
matrix 4 == matrix 6
What do you think? Does it make your task easier?
M.Prasanna kumar
M.Prasanna kumar le 8 Août 2019
no they are not equal..they are different sir

Connectez-vous pour commenter.

Réponse acceptée

darova
darova le 8 Août 2019
With use of pdist2()
A = [0 0]; B = [1 0]; C = [2 0];
[x,y] = meshgrid(0:2,1:2); % D G E H F I
D_I = [x(:) y(:)];
AtoXY = reshape(pdist2(A, D_I),size(x)); % matrix distance from A to (D G E H F I)
BtoXY = reshape(pdist2(B, D_I),size(x)); % distance from B
CtoXY = reshape(pdist2(C, D_I),size(x)); % distance from C
matrix1 = AtoXY + BtoXY;
matrix2 = AtoXY + CtoXY;
matrix4 = BtoXY + CtoXY;
  13 commentaires
M.Prasanna kumar
M.Prasanna kumar le 9 Août 2019
Modifié(e) : M.Prasanna kumar le 9 Août 2019
sir,
thank your very much for your kind reply. you were replying very patiently
code is working perfectly

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics and Optimization dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by