data cursor mode in GUI

10 ビュー (過去 30 日間)
Sukuchha
Sukuchha 2011 年 7 月 22 日
[EDIT: 20110722 11:46 CDT - reformat - WDR]
In normal way without any gui this works.
fig1= figure;
imshow (Photo)
dcm_obj1 = datacursormode(fig1);
cursor_info1 = getCursorInfo(dcm_obj1);
for i = 1:length(cursor_info1)
SEL_PX(i,:)=cursor_info1(1,i).Position;
end
Now I want to implement same thing with in a gui ! I have a axes named axes_2d.
Fig1 = handles.axes_2d
imshow (photo)
% this doesnot work why ??
dcm_obj1 = datacursormode(Fig1);
it says
??? Error using ==> datacursormode at 138 Invalid figure handle
  2 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 7 月 22 日
Please format the question: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Sukuchha
Sukuchha 2011 年 7 月 23 日
Oleg, thanks for the link ! Will do that from next time !

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 7 月 22 日
datacursormode() must be applied to a figure, not to an axes
  2 件のコメント
Sukuchha
Sukuchha 2011 年 7 月 23 日
Walter, could you explain a bit !
In case of GUI, whole GUI is a figure. If i have two axeses then how would i read datacursor value from those axeses.
Walter Roberson
Walter Roberson 2013 年 1 月 4 日
If you have multiple axes in a figure, then if you are using the default information function, MATLAB will figure out which axes you are on, just the same way as it needs to figure out which line or surface or image you are on or nearby.
If you are using a custom datacursor function, the figure coordinates are going to be passed into it, and you will need to figure out yourself which axes and object you are over, in order to present relevant information (which might include no information if it not over something you want to present information on.) A useful but undocumented internal tool for this purpose is overobj()

サインインしてコメントする。


Nima Nikvand
Nima Nikvand 2013 年 1 月 4 日
編集済み: Nima Nikvand 2013 年 1 月 4 日
Hello,
Instead of
Fig1 = handles.axes_2d;
datacursormode(Fig1);
you should apply datacursormode to the whole figure, here you are applying datacursormode to an axis, hence you get the error which says your figure handle is invalid!

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by