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:
Setting multiple property values to different handles in one line

Subject: Setting multiple property values to different handles in one line

From: Nate Jensen

Date: 10 Oct, 2011 12:48:08

Message: 1 of 3

I am wondering if there is a compact way of doing the following,

h = 1x2 vector of graphics handles
pos = 2x4 matrix of positions of each graphics handle

set(h(1),'Position',pos(1,:))
set(h(2),'Position',pos(2,:))

I thought it would be something like,

set(h,'Position',pos)

but that doesn't work.

Is what I'm asking possible?

Subject: Setting multiple property values to different handles in one line

From: Steven_Lord

Date: 10 Oct, 2011 13:11:26

Message: 2 of 3



"Nate Jensen" <natejensen88@gmail.com> wrote in message
news:j6upi8$244$1@newscl01ah.mathworks.com...
> I am wondering if there is a compact way of doing the following,
>
> h = 1x2 vector of graphics handles
> pos = 2x4 matrix of positions of each graphics handle
>
> set(h(1),'Position',pos(1,:))
> set(h(2),'Position',pos(2,:))
>
> I thought it would be something like,
>
> set(h,'Position',pos)
>
> but that doesn't work.
>
> Is what I'm asking possible?

You would need to turn pos into an appropriately sized cell array and
specify the property name as {'Position'} but yes. See the last example in
the reference page for SET.

http://www.mathworks.com/help/techdoc/ref/set.html

Of course, for something this simple, either a short FOR loop or the
manually unrolled version you posted seem like they'd be simpler.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Setting multiple property values to different handles in one line

From: Nate Jensen

Date: 10 Oct, 2011 13:35:11

Message: 3 of 3

"Steven_Lord" <slord@mathworks.com> wrote in message <j6uqtu$72o$1@newscl01ah.mathworks.com>...
> You would need to turn pos into an appropriately sized cell array and
> specify the property name as {'Position'} but yes. See the last example in
> the reference page for SET.
>
> http://www.mathworks.com/help/techdoc/ref/set.html
>
> Of course, for something this simple, either a short FOR loop or the
> manually unrolled version you posted seem like they'd be simpler.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thanks. Yes, you are correct Steve, if what I showed in my example was as simple as that, I wouldn't even need to ask. My code is more complicated though and I thought that a simpler example would be solved much more quickly.

Thanks again for the help, I appreciate it.

Tags for this Thread

No tags are associated with 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