How to plot the second point of line at mouse location
6 views (last 30 days)
I'd like to plot a line defined by two points, one that is already selected in [x,y] space, and the other that is unselected, but previewed by plotting the second point at the current position of the mouse (get(h,'CurrentPoint')).
Additionally, a plot object shows the resulting line between these two points as the cursor moves in the window.
The second point is selected with a mouse click.
KSSV on 1 Aug 2018
P = rand(1,2) ;
axis([-1 1 -1 1])
pts = zeros(,2) ;
for i = 1:10
[px,py] = getpts() ;
pts(i,:) = [px py] ;
plot([P(1,1) pts(i,1)],[P(1,2) pts(i,2)],'r')
double click , at a desired point when figure is opened.