Free hand drawing in Matlab with output is XY coordinate of trajectory.
41 views (last 30 days)
How i can free draw any trajcetory with the output is the XY coordinate of trajectory like in the picture. I just try to find in the answer in form but did no find any answers satisfiing the requirement. Tks you for any answer.
Adam Danz on 14 Nov 2018
Edited: Adam Danz on 14 Nov 2018
This might be what you're looking for. ginput() allows you to click on a graph as many times as you'd like and it returns a 2-column matrix of x,y coordnates where you clicked.
Run this, click around the axes, press Enter to see where you clicked. xy will be the coordinate of your clicks.
xy = ginput(); % now click as many coordinates as you'd like then press Enter when finished.
plot(xy(:,1), xy(:,2), 'bo', 'MarkerSize', 8, 'MarkerFaceColor', 'b');
This version plots as you click instead of plotting at the end. Press Enter to stop. xy will be the coordinate of your most recent click.
axh = axes;
xy = [0,0];
xy = ginput(1);
plot(axh, xy(1), xy(2), 'bo', 'MarkerSize', 8, 'MarkerFaceColor', 'b');
More Answers (1)
Peter Seibold on 29 Aug 2023
Another demo that stores the xy values:
disp('click inside figure')
disp('hit "return" button to finish')
axh = axes;
xlim([0,2])% change the limits to your requirements
ylim([0,1])% change the limits to your requirements
xyTemp = [0,0];
xyTemp = ginput(1);
plot(axh, xyTemp(1), xyTemp(2), 'bo', 'MarkerSize', 6, 'MarkerFaceColor', 'b');
disp('Previous to a second run you may resize the figure to your requirements')