i want to find distances between coordinate points as i explained below?? any help??
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
M.Prasanna kumar
el 7 de Ag. de 2019
Comentada: darova
el 10 de Ag. de 2019
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 comentarios
darova
el 8 de Ag. de 2019
matrix 1 == matrix 3
matrix 2 == matrix 5
matrix 4 == matrix 6
What do you think? Does it make your task easier?
Respuesta aceptada
darova
el 8 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Mathematics and Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!