Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Ha

Date: 1 Dec, 2009 03:33:03

Message: 1 of 7

I have a graphic object in a figure marked as 'Tag'='haha' and an object in another figure marked as the same. Then if I run findobj('Tag','haha') in the scripts of the former figure, it returns a handle array of two elements. So, how can I prevent the visibility of the object with 'Tag'='haha' in the latter figure from findobj command in the former figure?

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Herve

Date: 1 Dec, 2009 07:36:05

Message: 2 of 7

"Ha " <scifiles@126.com> wrote in message <hf22pf$2tr$1@fred.mathworks.com>...
> I have a graphic object in a figure marked as 'Tag'='haha' and an object in another figure marked as the same. Then if I run findobj('Tag','haha') in the scripts of the former figure, it returns a handle array of two elements. So, how can I prevent the visibility of the object with 'Tag'='haha' in the latter figure from findobj command in the former figure?

You could change the Tag of your first object before running findobj and set it back just after...

set('your_1st_graphic_object','Tag','hoho')
findobj('Tag','haha')
set('your_1st_graphic_object','Tag','haha')

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Pekka Kumpulainen

Date: 1 Dec, 2009 07:58:04

Message: 3 of 7

"Herve " <michaud_rene@yahoo.fr> wrote in message <hf2h15$363$1@fred.mathworks.com>...
> "Ha " <scifiles@126.com> wrote in message <hf22pf$2tr$1@fred.mathworks.com>...
> > I have a graphic object in a figure marked as 'Tag'='haha' and an object in another figure marked as the same. Then if I run findobj('Tag','haha') in the scripts of the former figure, it returns a handle array of two elements. So, how can I prevent the visibility of the object with 'Tag'='haha' in the latter figure from findobj command in the former figure?
>
> You could change the Tag of your first object before running findobj and set it back just after...
>
> set('your_1st_graphic_object','Tag','hoho')
> findobj('Tag','haha')
> set('your_1st_graphic_object','Tag','haha')

Or you could limit the search to the correct figure.
findobj(gcf,'Tag','haha')
or possibly
findobj(gcbf,'Tag','haha')
Generally it would be easier not to use the same Tag. Unless you have several instances of the same gui running.

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Ha

Date: 1 Dec, 2009 08:22:03

Message: 4 of 7

"Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in message <hf2iac$jp3$1@fred.mathworks.com>...
> "Herve " <michaud_rene@yahoo.fr> wrote in message <hf2h15$363$1@fred.mathworks.com>...
> > "Ha " <scifiles@126.com> wrote in message <hf22pf$2tr$1@fred.mathworks.com>...
> > > I have a graphic object in a figure marked as 'Tag'='haha' and an object in another figure marked as the same. Then if I run findobj('Tag','haha') in the scripts of the former figure, it returns a handle array of two elements. So, how can I prevent the visibility of the object with 'Tag'='haha' in the latter figure from findobj command in the former figure?
> >
> > You could change the Tag of your first object before running findobj and set it back just after...
> >
> > set('your_1st_graphic_object','Tag','hoho')
> > findobj('Tag','haha')
> > set('your_1st_graphic_object','Tag','haha')
>
> Or you could limit the search to the correct figure.
> findobj(gcf,'Tag','haha')
> or possibly
> findobj(gcbf,'Tag','haha')
> Generally it would be easier not to use the same Tag. Unless you have several instances of the same gui running.

Thanks, findobj(gcf,'Tag','haha') works well.

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Steven Lord

Date: 1 Dec, 2009 15:05:45

Message: 5 of 7


"Ha " <scifiles@126.com> wrote in message
news:hf22pf$2tr$1@fred.mathworks.com...
>I have a graphic object in a figure marked as 'Tag'='haha' and an object in
>another figure marked as the same. Then if I run findobj('Tag','haha') in
>the scripts of the former figure, it returns a handle array of two
>elements. So, how can I prevent the visibility of the object with
>'Tag'='haha' in the latter figure from findobj command in the former
>figure?

In addition to the other suggestions you've received, you could change the
HandleVisibility property of one of the objects. However, the solution I'd
probably use is to change the Tag for one of the objects (permanently)
unless I had a very good reason for having two objects with the same Tag.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Ha

Date: 2 Dec, 2009 03:56:06

Message: 6 of 7

"Steven Lord" <slord@mathworks.com> wrote in message <hf3b9o$oog$1@fred.mathworks.com>...
>
> "Ha " <scifiles@126.com> wrote in message
> news:hf22pf$2tr$1@fred.mathworks.com...
> >I have a graphic object in a figure marked as 'Tag'='haha' and an object in
> >another figure marked as the same. Then if I run findobj('Tag','haha') in
> >the scripts of the former figure, it returns a handle array of two
> >elements. So, how can I prevent the visibility of the object with
> >'Tag'='haha' in the latter figure from findobj command in the former
> >figure?
>
> In addition to the other suggestions you've received, you could change the
> HandleVisibility property of one of the objects. However, the solution I'd
> probably use is to change the Tag for one of the objects (permanently)
> unless I had a very good reason for having two objects with the same Tag.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>

The reason why I asked this question is, as you said, I run several instances synchronously. Changing findobj('Tag',xxx) into findobj(gcf,'Tag',xxx) is a convinient way to solve my problem. Thanks for your reply.

Subject: How to hide 'Tag' of an object in a figure from the findobj() command in another figure?

From: Nick

Date: 3 Dec, 2009 03:53:03

Message: 7 of 7

"Ha " <scifiles@126.com> wrote in message <hf22pf$2tr$1@fred.mathworks.com>...
> I have a graphic object in a figure marked as 'Tag'='haha' and an object in another figure marked as the same. Then if I run findobj('Tag','haha') in the scripts of the former figure, it returns a handle array of two elements. So, how can I prevent the visibility of the object with 'Tag'='haha' in the latter figure from findobj command in the former figure?

Make the tag in one just haha1
             tag in other just haha2
This should solve all your problems

Tags for this Thread

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.

Contact us