How to get the coordinate value on the Matlab script for further coding from the previous graph?

조회 수: 1 (최근 30일)
How to get the select/label two nodes from graph to be source and target?And transfer the node information(position value/coordinates) on the editor for more coding later?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2017년 3월 18일
Sneha - please clarify what you mean by How to get the select/label two nodes from graph to be source and target. Do you want to be able to click on two nodes, the first being the source and the second the target? And you want to store these values somewhere? I'm not sure what you mean by on the editor unless you want this information to be displayed in the workspace. Is the above axes in a GUI or is it just drawn from the command line?

댓글을 달려면 로그인하십시오.

채택된 답변

Alain Kuchta
Alain Kuchta 2017년 3월 21일
My understanding is that you would like to select points in a figure (in this case a plot of a graph) and retrieve the values of the selected points programmatically. I am assuming that the points you want to select are on one of the lines of your graph or a vertex of the graph.
1) Use Data Brushing to select points. For more information about data brushing, refer to the following link:
The brush command also can be used to start Data Brushing programmatically. For more information, refer to the following link:
2) Acquire the brushed points programmatically:
p = plot(x,y);
% do data brushing manually
bd = logical(get(p, 'BrushData'));
brushed_x = p.XData(bd);
brushed_y = p.YData(bd);
See also this MATLAB Answers question:

추가 답변 (1개)

Sneha Kolapalli
Sneha Kolapalli 2017년 4월 5일
[xp,yp] = ginput(2)
It will returns the 2 values of x, and 2 values of y for the two points you click on the figure. If the number in ginput is changed to 'n', 'n' points can be selected.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by