Output from programmatic GUI

6 views (last 30 days)
Erin
Erin on 21 Jul 2014
Commented: Erin on 25 Jul 2014
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.

Accepted Answer

Joseph Cheng
Joseph Cheng on 21 Jul 2014
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
  3 Comments
Joseph Cheng
Joseph Cheng on 21 Jul 2014
So i generated a test GUIDE file that generates a non-GUIDE gui.
So if you look at the example of how i initialize the handles.GenNumbers pass it from the non-GUIDE gui, etc. it may show you what you need to do to accomplish your task.
So the example file you have two push buttons. the 'dynamic GUI return' button will display what is generated by the dynamic gui function. the 'Dynamic GUI' button will call up a dynamically generated gui which you can push the button GenSomething. it'll display a series of numbers which if you go back to the main GUIDE Gui you can hit the 'Dynamic GUI return' button to display the same numbers.
Erin
Erin on 25 Jul 2014
Thanks so much for your help! Using the GUI handles really streamlined the code. I also had to put in
handles = GUI(hObject)
before using guidata in the main function to make sure I got the updated handles.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!