how get value at pos(3) position by using "datacursormode on" in axes ???
Ältere Kommentare anzeigen
This is my coding :
%%----->DO 2D CONTOUR MAP<-----%%
B = get(handles.uitable2,'Data');
[C,h] = contourf(B); %countour map the excel in 2D with handles
set(h,'LineWidth',2) %handles line width with "2"
im builde the GUIDE in MATLAB....
The question is, how can i retrieve value at pos(3) position by using "datacursormode on" to display at editbox??? can u continue my command please... URGENT...
1 Kommentar
Geoff Hayes
am 3 Mär. 2017
muhammad - please don't post your question in multiple threads, especially as an answer to another question.
Akzeptierte Antwort
Weitere Antworten (1)
Geoff Hayes
am 3 Mär. 2017
muhammad - I suspect that you will need to do something similar to https://www.mathworks.com/matlabcentral/answers/157879-how-to-pass-the-variables-to-data-cursor-s-updatefcn-datacursormode-in-matlab-guide. You will need to do
handles.dcm_obj = datacursormode(hObject);
set(handles.dcm_obj,'Enable','on','UpdateFcn',{@myupdatefcn,hObject});
In the myupdatefcn callback, you will need to define the text string (similar to the output you have shown in the image). As this uses pos, then you have access to the third element which you can set back in the edit text field of your GUI since we are assuming that the hObject passed into this callback (when set above) is the handle to the figure.
function txt = myupdatefcn(~,event_obj,hFigure)
pos = get(event_obj,'Position');
txt = 'something using pos';
handles = guidata(hFigure);
if isfield(handles,'text1')
set(handles.text1,'String',num2str(pos(3)));
end
The above assumes that text1 is the control to update with your text.
6 Kommentare
muhammad zulhelmy
am 4 Mär. 2017
Geoff Hayes
am 4 Mär. 2017
Yes, you would need to review all of the code from the link I posted. The hObject that you pass
datacursormode(hObject)
is the handle to the figure hence the error message
Invalid figure handle
since you are passing the handle to a uicontrol (probably a button).
Walter posted a better solution, so I would go with that.
muhammad zulhelmy
am 4 Mär. 2017
muhammad zulhelmy
am 4 Mär. 2017
muhammad zulhelmy
am 5 Mär. 2017
muhammad zulhelmy
am 5 Mär. 2017
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

