Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you pass data between GUI m-files?

161 views
Skip to first unread message

Jack E. Moore III

unread,
Mar 14, 2007, 2:40:52 PM3/14/07
to
I am attempting to construct a GUI with multiple figures involved.
The problem is I do not see an efficient means of passing data
between the m-files. So far the only thing I've come up with is
setting the string of an object in the GUI I'm switching to the data
I want to pass. Then in the new GUI's m-file I read it. But this does
not seem to work very efficiently and can't really work when I'm
waning to pass and array of values to a new GUI. So does anyone have
a suggestion?

Jack E. Moore III

PS- Also if anyone knows how to call a function from one m-file that
is defined in a seperate m-file this would probably fix the data
passing problem easily.

Ken Garrard

unread,
Mar 14, 2007, 2:54:19 PM3/14/07
to
You could save the data to the hard drive in a .mat file. Not
particularly elegant or efficient, but it is very simple. It is a
good way to implement a gui that invokes another gui to manage
persistent data such as preferences since these need to be saved
anyway.

I would recommend using the function syntax forms of the load and
save commands. Check the documentation for examples.

Ken

Rob C

unread,
Mar 14, 2007, 3:19:34 PM3/14/07
to
I've done this before but its round about and I cant recall how I did
it off the top of my head. The GUI is on my laptop at my house and I
will check it when I get home from the office this afternoon and post
up how I did it if no one else has by then.

-Rob

Scott Seidman

unread,
Mar 14, 2007, 3:34:05 PM3/14/07
to
"Jack E. Moore III" <jmoo...@mix.wvu.edu> wrote in news:ef5079f.-1
@webcrossing.raydaftYaTP:


Use "guidata", and be careful keeping track of stuff. Another trick is to
create a figure with visibility off, and use this as a central storage
facility.


--
Scott
Reverse name to reply

Gary

unread,
Mar 14, 2007, 3:44:43 PM3/14/07
to
To write:
setappdata(0,'name',variablename);

To read:
variablename=getappdata(0,'name');

Jack E. Moore III

unread,
Mar 15, 2007, 10:11:17 AM3/15/07
to

Dear god, thank you. It's so great to just try a command and it just
works...

Jack E. Moore III

Gary

unread,
Mar 15, 2007, 10:59:21 AM3/15/07
to
> Dear god, thank you. It's so great to just try a command and it
> just
> works...

You're welcome. Something to be aware of though: That '0' refers to
the Matlab root, meaning that when you close your figures, that data
space still exists. If you need to clear such a variable, use
rmappdata(0,'name').

Ronen

unread,
Aug 18, 2010, 8:00:19 PM8/18/10
to
"Jack E. Moore III" <jmoo...@mix.wvu.edu> wrote in message <ef507...@webcrossing.raydaftYaTP>...

I use the figure property called UserData.

set(figure(1) , 'UserData', rand(3))

get(figure(1), 'UserData')

= 0.8147 0.9134 0.2785
0.9058 0.6324 0.5469
0.1270 0.0975 0.9575

0 new messages