user interface - In a MATLAB GUI, extract coordinates by clicking inside a plot and display it -
i'm pretty new matlab, have looked everywhere solution problem :
let's use gui example :
how can i, clicking somewhere inside plot, display x
coordinate in text box ?
here's code tried in gui code, couldn't work :
function axes1_buttondownfcn(hobject, eventdata, handles) [x y] = get(gca,'currentpoint'); set(handles.edit1,'string', num2str(x)); guidata(hobject, handles);
edit: oh, misread question. pushed original answer bottom of post. might still useful. here go:
function axes1_buttondownfcn(hobject, eventdata, handles) [x y] = eventdata; set(handles.edit1,'string', num2str(x)); guidata(hobject, handles);
note, i've seen instances eventdata doesn't work. if try use , it's empty, let me know , i'll try walk through doing using custom datacursormode tooltip callback function, more complex, doable.
original:
datacursormode on
for additional information see this page. i've done lot of work custom data cursor mode functions, , plot-clicky things, if have more specfic questions, feel free ask.
Comments
Post a Comment