Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!news.aset.psu.edu!support1.mathforum.org!not-for-mail
From: bogfrog <jmcgraw@rcn.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: passing images between two GUI
Date: Fri, 08 Aug 2008 23:53:44 EDT
Organization: The Math Forum
Lines: 30
Message-ID: <14431363.1218254054696.JavaMail.jakarta@nitrogen.mathforum.org>
References: <g7ir0p$9sf$1@fred.mathworks.com>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1218254054 11467 144.118.30.135 (9 Aug 2008 03:54:14 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Sat, 9 Aug 2008 03:54:14 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:484629



> it gives me this error
> 
>  Undefined function or variable 'hMainGui'.
> 
> Error in ==> Main>Main_OpeningFcn at 56
> setappdata(hMainGui,'C',imageMatrix);

If you are in your main opening function, for the main gui, before that line (where you get the error), you should have:

setappdata(0,'hMainGui',gcf)
hMainGui = getappdata(0,'hMainGui')

then you can do

setappdata(hMainGui,'C',imageMatrix);


See, '0' is the handle to the root workspace.  So in the first line above, I save the gui handle (gotten by gcf) to a application datum I call "hMainGui" stored in the root workspace.  Then I get it from the root (2nd line) and assign it to a variable called hMainGui.  Now the hMainGui handle is defined.


> i would really appreciate it if u gave me more
> details ..
> like what should i write in the pushbutton callback?

that depends on what you want the pushbutton to do.  I'm not familiar enough with what you're doing to answer. But if you want to access the image data, assuming you build on the same code as above, you would do this:

hMainGui = getappdata(0,'hMainGui');
image = getappdata(hMainGui,'C')

now the image should be stored in 'image'