i want to find distances between coordinate points as i explained below?? any help??
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
darova
2019-8-8
matrix 1 == matrix 3
matrix 2 == matrix 5
matrix 4 == matrix 6
What do you think? Does it make your task easier?
采纳的回答
darova
2019-8-8
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!