Share data from a function to pushbutton call back in gui
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Geoff Hayes
el 3 de Mayo de 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 comentarios
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!