How to get cursor information of data tips using call back of a push buttion?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a fairly simple code. All I want is user to select multiple data tips (Alt+left mouse button) from a plot and on clicking a push button, the position and data index of the data tips be written in a structure. The command, c_info = cursorMode.getCursorInfol; gives me the required output but not when used in a callback function. Please suggest a way to assign the above command to a push button. Thanks for the help! First draft of the code is herewith:
function [] = GUI_me(varargin)
fh = figure('units','pixels',...
'position',[200 100 500 560],...
'menubar','none',...
'name','GUI_1',...
'numbertitle','off',...
'resize','off');
z = peaks;
plot(z(:,30:35))
dcm_obj = datacursormode(fh);
set(dcm_obj,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on')
pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 180 40],...
'fontsize',14,...
'string','Done',...
'callback',{@pb_call});
pb2 = uicontrol('style','push',...
'units','pix',...
'position',[300 10 180 40],...
'fontsize',14,...
'string','Clear data tips',...
'callback',{@pb2_call});
function [] = pb2_call(varargin) % Clears user selected data tips
cursorMode = datacursormode(gcf);
cursorMode.removeAllDataCursors();
function [] = pb_call(varargin) % Returns the position and data index of selected data tips
% Callback for pushbutton.
cursorMode = datacursormode(gcf);
c_info = cursorMode.getCursorInfo;
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Visual Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!