MATLAB: How to run the callback routine for a pushbutton from the command line in MATLAB 7.0.4 (R14SP2)

.mcallbackcommandfilefromfunctionguilineMATLABobject

I want to execute a GUI object callback function from the MATLAB Command line, or another function.

Best Answer

One way to run the callback function from the Command Window is to run the GUI function with arguments including the appropriate callback function, the handle to the object associated with the callback function, the event, and the 'handles' structure.
The easiest way to obtain the necessary information is to make the 'handles' structure the output of the GUI code. To do this, change the following line in GUI create function "myGUI_CreateFcn":
handles.output = hObject;
to
handles.output = handles;
then execute the following at the MATLAB Command Prompt
h = myGui;
myGui('pushbutton1_Callback',h.pushbutton1,[],guidata(h.pushbutton1))
The above example executes the callback function for a pushbutton object with an object 'Tag' property set to 'pushbutton1'.