with the help of datacursormode and getposition, I am able to find the coordinates of selected points , how can I save those coordinates...?

hdt = datacursormode;
set(hdt,'UpdateFcn',{@labeldtips,hdt});
dcs=hdt.DataCursors;
pos = get(dcs(1),'Position'); %Position of 1st cursor
output_txt{1} = ['X: ', num2str(pos(1))];
output_txt{2} = ['Y: ', num2str(pos(2))];

1 Comment

@supriya kadam: today I formatted your code correctly for you. In future please do it yourself by first selecting the code text and then clicking the {} Code button. It really is that easy!

Sign in to comment.

Answers (1)

data cursor mode is not appropriate for saving points. Use ginput(), or impoint(); or put an axes ButtonDownFcn callback and in that callback get() the axes CurrentPoint property.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 11 Jan 2016

Answered:

on 11 Jan 2016

Community Treasure Hunt

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

Start Hunting!