fg=figure; disp('Let''s draw a nice picture'); disp('When finished, press right mouse button'); [x,y,t]=ginput(1); plot(x,y,'o'); xx=x; yy=y; hold; axis([0 1 0 1]); while t~=3 [x,y,t]=ginput(1); plot(x,y,'o'); xx=[xx,x]; yy=[yy y]; end clf; line(xx,yy) disp('Click on figure when finished'); waitforbuttonpress delete(fg)