Info

This question is closed. Reopen it to edit or answer.

please delete this question

1 view (last 30 days)
satoshi oi
satoshi oi on 21 Jun 2018
Closed: satoshi oi on 25 Jun 2018
please delete this question

Answers (1)

mizuki
mizuki on 22 Jun 2018
Edited: mizuki on 23 Jun 2018
dt.Points の1列目がx点のインデクス、2列目がy点のインデクスになります。それぞれの座標を edges 関数で求めるとxの長さ、yの長さが求まると思います。ピタゴラスの定理で斜辺を求めれば距離が計算できます。
% 変数定義
rng(0)
x = rand(10,1);
y = rand(10,1);
xy = [x y];
dt = delaunayTriangulation(x,y);
edge_idx = edges(dt);
%%TRIPLOT を使った描画
triplot(dt)
%%距離計算
xpts = x(edge_idx);
ypts = y(edge_idx);
xdist = abs(xpts(:,1) - xpts(:,2));
ydist = abs(ypts(:,1) - ypts(:,2));
xydist = sqrt(xdist.^2 + ydist.^2);
graph 関数を使うと扱いやすい&きれいなvisualizeができます。
%%GRAPH を使った描画
EdgeTable = table(edge_idx,'VariableNames',{'EndNodes'});
G = graph(EdgeTable);
G.Edges.Weight = xydist;
h = plot(G, 'EdgeLabel', G.Edges.Weight);
h.XData = x;
h.YData = y;

Tags

Community Treasure Hunt

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

Start Hunting!