Returning variables to the main GUI workspace after a second GUI window is closed

Returning variables to the main GUI workspace after a second GUI window is closed

Post by Howard Goldows » Sun, 24 Mar 2002 02:07:53



Hello MATLAB Gurus,

I was wondering if anyone can help me with this problem: I have a main
GUI figure, and in this figure I initialize a structure called "team".
The user clicks on a button in the main figure, and the
button1_callback then calls a function that opens another figure. In
this second figure the "team" structure is modified. When the user
closes the second figure I would like to pass the modified "team"
structure back to the main figure. I know how to pass the "team"
structure TO the second figure, but I don't know how to pass my
strucutre BACK FROM the second figure. Below is some of my code. Also,
is there a better way to pass data from one figure to another besides
how I am doing it?

Thanks for any help!
====================

% create original figure and global handles structure
handles = guihandles(fig);

% Initialization of my own global structure "team".
    team = Initialization();
    handles.team = team;

% Save "team" structure to handles structure.
    guidata(fig,handles);  

======
function varargout = pushbutton1_Callback(h, eventdata, handles,
varargin)

done = Launch_figure2(handles.team);

======

function done = Launch_figure2(team);

        % Open the figure
        fig = openfig('figure2','reuse');
        % Use system color scheme for figure:
        set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
        % Generate a structure of handles to pass to callbacks, and store it.
        handles = guihandles(fig);

        % Pass Global variables to figure2 handles
        handles.team = team;

        % save handles structure for new fig
        guidata(fig,handles);      

        % This function returns to the callback
        done = 1;      

============

So at this point figure 2 has the structure "team" in it's workspace
ready to be modified, but I don't know how to return the modified
structure back to figure 1. Any suggestions would be helpful. THanks!

Howard

 
 
 

Returning variables to the main GUI workspace after a second GUI window is closed

Post by per isakso » Sun, 24 Mar 2002 07:13:12


This question has been much discussed in this group. Search for Guidemo
by Jordan Rosentahl in comp.soft-sys.matlab. Use

http://groups.google.com/groups?hl=sv&safe=off&group=comp.soft-sys.ma...

However, I'm not happy with the side effects of  uiwait. E.g. it causes me much
grief during development. Depends if you like to make the second Gui modal -
I don't, especially not not if the user is supposed to interact with the second
Gui
for more than a few seconds. I often use a pushbutton, <save>, and a callback,
in which I write the result to appdata of the first Gui. I also tried to pass a
return
argument name as an input argument and return the value using assignin in the
calback of  <done> (or <close>) . I like both better than the uiwait contstruct.

- per isakson


> Hello MATLAB Gurus,

> I was wondering if anyone can help me with this problem: I have a main
> GUI figure, and in this figure I initialize a structure called "team".
> The user clicks on a button in the main figure, and the
> [ snip ]


 
 
 

1. problems reading main workspace variables into Femlab GUI workspace (I think)

Hi.

I'm trying to modify a femlab .m program so that I can run it from a matlab
command line, or interactively by reading it into femlab.  For example:

I'd like to do something like:

fem.sol=femtime(fem,'tlist',  0:dt:total_time,...

where dt and total_time might be variables in a loop, so that I could
quickly solve for many different time domains without sitting at the
femlab GUI.  I'd still like the option of running this via the gui
(without the loop, but with dt and total_time defined), so then the
user could interactively change things after it's run and run it again.

To this end I had femlab save an .m file.  I can correctly read this m file
back into the gui and run it.  I then modified the .m file to add some
variables (eg, dt, total_time, diffusion coefficients, etc) and saved it
as a new .m file.  I can run this file from matlab and it seems to work
fine, I can even get a postplot up of the results automatically.

The strange thing is, when I pop up the femlab gui, and read in the .m
file, and it runs it, it bombs.  The exact same file that runs inside
matlab.  It says (after creating a mesh) "mass matrix must have some
non-zero entries".  I am passing all my variables in via a
fem.variables = {'diffusion',diffusion, ...
sort of structure, eg, I have matlab variable called diffusion that is set
to some number then passed in this way.
I'm thinking that somehow these variables are being evaluated in some sort
of gui workspace where they are all zero maybe??  but why should that be,
since if the .m file is all in the gui workspace, when I set diffusion = 5
it would be set in that workspace.  So I'm just guessing.

I tried changing from 'context','local'   to 'context','main'   in all
the calls that used it. that made no difference.
I tried putting print statements into the file (eg, dispcell(fem.variables)),
but that always halted the program saying the variable wasn't defined.
I've tried exporting fem to the matlab workspace after it bombs, to look
at it, but that always generates some sort of error (eg, "inconsistent 'dim'
fields).  I've also noticed that although I'm using multiphysics with 3
whatever_they_are_called (ie, appl{1}, appl{2}, and appl{3}), the gui
only shows one under the multiphysics menu; I'm assuming that is because it's
not getting the variables somehow??

I repeat, it all seems to run fine from matlab (no femlab gui).
Does anyone have any ideas?
Thanks.
                Larry

2. Does mysql save to a temp file??

3. Variables in Workspace, Saving Variables after GUI Application is Closed

4. NIS/YP clients for VMS?

5. Combning GUI and workspace: How can a velue be returned from a GUI?

6. DOS doesn't recognize disk change

7. How do I make the return key close GUI figure ?

8. want GUI to return data to function workspace, not base

9. GUI and a main frame (window)

10. Close-Request for main window

11. closing GUI with close

12. GUI Variable Return