Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

please delete this question

1 visualizzazione (ultimi 30 giorni)
satoshi oi
satoshi oi il 21 Giu 2018
Chiuso: satoshi oi il 25 Giu 2018
please delete this question

Risposte (1)

mizuki
mizuki il 22 Giu 2018
Modificato: mizuki il 23 Giu 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;

Tag

Community Treasure Hunt

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

Start Hunting!