Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: grouping plot handles?
Date: Wed, 9 Apr 2008 15:50:19 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 31
Message-ID: <ftiojr$pq6$1@fred.mathworks.com>
References: <ftiik2$7ni$1@fred.mathworks.com> <ftikv3$h37$1@fred.mathworks.com> <ftinsq$at6$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1207756219 26438 172.30.248.37 (9 Apr 2008 15:50:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 9 Apr 2008 15:50:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:462008




> 
> Heres another problem i'm having:
> in a for loop, i have this statement:
> 
> 	if ismember('hNewCam', who) == 1
> 		delete(hNewCam);
> 	end
> 
> which is just to prevent the handle from being delete the
> first time through the loop (since it doesn't exist yet). 
> The thing is, I get this error:
> 
> ??? Error using ==> delete
> Invalid handle object.
> 
> but if I put a breakpoint at the beginning of the loop and
> delete(hNewCam) manually, it works fine!!??
> 


Try it this way.  Initialize hNewCam before the loop to be 
empty:

hNewCam = [];

Then, within the loop, use this construct:

if ishandle(hNewCam)
  delete(hNewCam)
end