Finding the coordinates of nodes in a plot

조회 수: 6 (최근 30일)
Melisa Gunes Pullu
Melisa Gunes Pullu 2021년 12월 28일
답변: Sulaymon Eshkabilov 2021년 12월 28일
There are randomly positioned nodes named like 1, 2, 3 etc. in a plot and I will obtain a path from these nodes like path = [5 8 19 4]. How can I find the coordinates of each node in the path in the form
coordinates = [x y
x1 y1
x2 y2].
Thank you.

답변 (2개)

Yusuf Suer Erdem
Yusuf Suer Erdem 2021년 12월 28일
Try these codes below please;
x = linspace(0,2,20)';
y = sin(x);
h=plot(x,y)
a=get(h,'XData');
b=get(h,'YData');
c=vertcat(a,b)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 12월 28일
If understood your question correctly, what you are trying to achieve is to locate the points in the plotted data. If so,
a = 1:5;
b = randi(15, 1, 5);
plot(a, b,'ro-')
[x,y] = ginput(5);

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by