Share data from a function to pushbutton call back in gui
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
i need data1 in this function for several operation
function output_txt = labeldtips(obj,event_obj,hdt)
dcs=hdt.DataCursors;
pos = get(dcs(1),'Position');
output_txt{1} = ['X: ', num2str(pos(1))];
output_txt{2} = ['Y: ', num2str(pos(2))];
data1=pos(2);
Can anyone help me ? Thanks in advance.
0 Kommentare
Antworten (2)
Geoff Hayes
am 3 Mai 2015
Mehedi - if you want data1 to be used by your pushbutton3 callback, then just add this variable to the output parameter list of the function. So something like
function [data1,output_txt] = labeldtips(obj,event_obj,hdt)
dcs=hdt.DataCursors;
pos = get(dcs(1),'Position');
output_txt{1} = ['X: ', num2str(pos(1))];
output_txt{2} = ['Y: ', num2str(pos(2))];
data1=pos(2);
would do the trick. Call it from your callback as
function pushbutton3_Callback(hObject, eventdata, handles)
% do stuff
% call function
[data1,output_txt] = labeldtips(....);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!