MATLAB: How to get variables from callback functions in MATLAB

callbackgui

I programmed a pushbutton that I want to call to @GetValue function.
The GetValue function creates 2 variables (PupilColumn,BehavColumn). I don't know how to take these variables out from the @GetValue function in order to use them later. How should I program it correctly?
[PupilColumn,BehavColumn]=CreatePush(Figure_h,ColumnPupil_h,ColumnBehav_h)
function CreatePush(Figure_h,ColumnPupil_h,ColumnBehav_h)
PushButton_h = uicontrol(Figure_h, 'Style', 'push', 'String', 'Next', ...
'Position', [600 20 120 50], ...
'CallBack',{@GetValue,ColumnPupil_h,ColumnBehav_h}, ...
'UserData',0);
end
function [PupilColumn,BehavColumn] = GetValue(PushButton_h,ed,ColumnPupil_h,ColumnBehav_h)

Best Answer

Daniel is correct that callbacks cannot return anything. See the FAQ on this topic for various methods.