1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| function output_txt = myfunction(obj,event_obj)
% Display the position of the data cursor
% obj Currently not used (empty)
% event_obj Handle to event object
% output_txt Data cursor text string (string or cell array of strings).
LineH=get(event_obj,'Target');
XDataV=LineH.XData;
pos = get(event_obj,'Position');
IndexX=find(pos(1)==XDataV);
XTickLabel=get(gca,'XTickLabel');
output_txt = {['X: ',(XTickLabel(IndexX,:))],...
['iX: ',num2str(IndexX,4)],...
['Y: ',num2str(pos(2),4)]};
% If there is a Z-coordinate in the position, display it as well
if length(pos) > 2
output_txt{end+1} = ['Z: ',num2str(pos(3),4)];
end |
Partager