From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: How to get gcf in base workspace from a GUI
Date: Thu, 9 Jul 2009 21:58:01 +0000 (UTC)
Organization: Brookhaven National Laboratory
Lines: 20
Message-ID: <h35p59$pvc$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1247176681 26604 (9 Jul 2009 21:58:01 GMT)
NNTP-Posting-Date: Thu, 9 Jul 2009 21:58:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1275055
Xref: comp.soft-sys.matlab:554277


I am trying to get a currently selected figure (gcf) created in the base workspace within a GUI function. For example, I just type "figure" in the Command Window and I get 1 as a handle to the figure.

I thought having

evalin('base', 'gcf')

in the GUI M-file would return 1 to me. But this only returns gcf in the GUI function workspace, not in the base workspace.

I also tried

get(0, 'CurrentFigure')

to see if I can get to gcf in the base by going through root (0), but only obtained again gcf in the GUI space. So, it appears that even the root is different, depending on whether it is queried from the base or GUI workspace.

Does anyone know how to accomplish my goal? Please let me know if you need more information or clarification of what I am trying to do.

Many thanks,