Thread Subject: grouping plot handles?

Subject: grouping plot handles?

From: David Doria

Date: 9 Apr, 2008 14:08:02

Message: 1 of 5

I would like to do this
%group 1
a=plot(0,1,'o');
b=plot(1,1,'ro');

%group 2
c=plot(1,2,'go');

delete(group 1)

how would I do that?

Thanks

Dave

Subject: grouping plot handles?

From: helper

Date: 9 Apr, 2008 14:48:03

Message: 2 of 5

"David Doria" <daviddoria@gmail.com> wrote in message
<ftiik2$7ni$1@fred.mathworks.com>...
> I would like to do this
> %group 1
> a=plot(0,1,'o');
> b=plot(1,1,'ro');
>
> %group 2
> c=plot(1,2,'go');
>
> delete(group 1)
>
> how would I do that?
>
> Thanks
>
> Dave

Try this:

 %group 1
group{1}(1) = plot(0,1,'o');
group{1}(2) = plot(1,1,'ro');
 
%group 2
group{2}(1) = plot(1,2,'go');
 
delete(group{1})

You could used "group1" and "group2" in place of "group{1}"
and "group{2}". However, I placed each group into a
different cell of a cell array so it will be easy for you
to create (for example) group{142} if you need to.

Subject: grouping plot handles?

From: David Doria

Date: 9 Apr, 2008 15:38:02

Message: 3 of 5

ah cool , i didn't realize you could delete an array of
function handles.

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!!??

any thoughts?

David
"helper " <spamless@nospam.com> wrote in message
<ftikv3$h37$1@fred.mathworks.com>...
> "David Doria" <daviddoria@gmail.com> wrote in message
> <ftiik2$7ni$1@fred.mathworks.com>...
> > I would like to do this
> > %group 1
> > a=plot(0,1,'o');
> > b=plot(1,1,'ro');
> >
> > %group 2
> > c=plot(1,2,'go');
> >
> > delete(group 1)
> >
> > how would I do that?
> >
> > Thanks
> >
> > Dave
>
> Try this:
>
> %group 1
> group{1}(1) = plot(0,1,'o');
> group{1}(2) = plot(1,1,'ro');
>
> %group 2
> group{2}(1) = plot(1,2,'go');
>
> delete(group{1})
>
> You could used "group1" and "group2" in place of "group{1}"
> and "group{2}". However, I placed each group into a
> different cell of a cell array so it will be easy for you
> to create (for example) group{142} if you need to.

Subject: grouping plot handles?

From: helper

Date: 9 Apr, 2008 15:50:19

Message: 4 of 5


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

Subject: grouping plot handles?

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 9 Apr, 2008 16:01:28

Message: 5 of 5

In article <ftiik2$7ni$1@fred.mathworks.com>,
David Doria <daviddoria@gmail.com> wrote:
>I would like to do this
>%group 1
>a=plot(0,1,'o');
>b=plot(1,1,'ro');

As you did not specify axes to plot(), both of them are going to
use the current axis (gca). Unless 'hold on' is in effect, that is
going to result in the second plot, 'b', replacing the first one, and
the handles in 'a' would become invalid.

>%group 2
>c=plot(1,2,'go');

Similarily, unless 'hold on', that would delete the plot 'b'.

>delete(group 1)

>how would I do that?

Unless your code is a bit different than what you show here, you
would not need to.
--
  "They called it golf because all the other four letter words
  were taken." -- Walter Hagen

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
cell arrays helper 9 Apr, 2008 10:50:24
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com