image thumbnail
from DispCoord1&2.m by Zhihua He
Display 2-D and 3-D coordinates.

DispCoord2
function DispCoord2
delete(findobj('style','text','backgroundcolor',[0 0 0],'foregroundcolor',[1 0 0]));
pos=get(gca,'CurrentPoint');
POS=mean(pos);
POS=round(POS*1000)/1000;
FPOS=get(gcf,'CurrentPoint');


if POS(3)==0.5
    disp(' Try the program only after you actually plot a figure!');
elseif POS(3)==0 | POS(3)==8.66
    uicontrol(gcf,'pos',[FPOS,120,15],...
        'style','text',...
        'string',['(',num2str(POS(1)),'  ,  ',num2str(POS(2)),')'],...
        'backgroundcolor',[0 0 0],...
        'foregroundcolor',[1 0 0],...
        'ButtonDownFcn','delete(gcbo)');
else
    uicontrol(gcf,'pos',[FPOS,120,15],...
        'style','text',...
        'string',['(',num2str(POS(1)),'  ,  ',num2str(POS(2)),')=',num2str(POS(3))],...
        'backgroundcolor',[0 0 0],...
        'foregroundcolor',[1 0 0],...
        'ButtonDownFcn','delete(gcbo)');
end

Contact us at files@mathworks.com