MATLAB: Output from programmatic GUI

function outputprogrammatic gui

Hi,
I have a function that creates a dynamic, programmatic GUI. This function is called from the callback of a GUIDE GUI, and I would like for it (the function) to output a matrix to this callback when a pushbutton is clicked w/in the programmatic GUI.
I am having problems setting the output of this function. The output is set w/in the callback of the pushbutton, but I do not know how to set it w/in the main function. I have tried defining the output in the main function and setting it w/in a nested function. However, I receive this error: Attempt to add "___________" to a static workspace. See MATLAB Programming, Restrictions on Assigning to Variables for details._
Is there a way for me to work around this error or another way to return the output value to the main function?
Thanks.

Best Answer

If i understand what you're attempting to do (get some value that is calculated within a pushbutton callback into the main gui). put it in the handles structure.
example:
function pushbutton_callback(hObject,event,handles)
CAlculatedItem = randi(10,10,10);
handles.PushbuttonOutput = CalculatedItem*10;
guidata(hObject,handles);
then in the main function you can retrieve it as handles.PushbuttonOutput