Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247176681 26604 172.30.248.38 (9 Jul 2009 21:58:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Jul 2009 21:58:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1275055
Xref: news.mathworks.com comp.soft-sys.matlab:554277

Hello,

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,
-Yoshi