Thread Subject: How to set a value to a group of gui object in a smple way?

Subject: How to set a value to a group of gui object in a smple way?

From: damayi

Date: 28 Dec, 2007 15:41:05

Message: 1 of 3

Dear all
I want to set a group of menu object's 'label' value in terms of my
requirement.
Below is an example code to illustrate my question.
% begin
LabelCell = {'Name'; 'Score'; 'Class'; 'Age'};
hm = [ 1.111, 2.222, 3.333, 4.444] % all the value is a handle to
a menu object.
for k = 1:numel(hm)
    set(hm(k), 'label', LabelCell{k});
end
% finished

In this way, I can carry my points. However, I think 'for-loop' maybe
replaced and I hope that can be realized in a more simple way. Any
idea about it?

Best Regards
damayi
2007-12-28

Subject: How to set a value to a group of gui object in a smple way?

From: Huy

Date: 28 Dec, 2007 16:01:54

Message: 2 of 3

damayi <damayi@gmail.com> wrote in message <a57b1eb8-2471-
465d-a144-bca8660c3464@l6g2000prm.googlegroups.com>...
> Dear all
> I want to set a group of menu object's 'label' value in
terms of my
> requirement.
> Below is an example code to illustrate my question.
> % begin
> LabelCell = {'Name'; 'Score'; 'Class'; 'Age'};
> hm = [ 1.111, 2.222, 3.333, 4.444] % all the value is
a handle to
> a menu object.
> for k = 1:numel(hm)
> set(hm(k), 'label', LabelCell{k});
> end
> % finished
>
> In this way, I can carry my points. However, I think 'for-
loop' maybe
> replaced and I hope that can be realized in a more simple
way. Any
> idea about it?
>
> Best Regards
> damayi
> 2007-12-28


arrayfun(@(h,newlab) set(h,'Label',newlab{1}), hm,LabelCell)


Anh Huy Phan
RIKEN - BSI

Subject: How to set a value to a group of gui object in a smple way?

From: damayi

Date: 29 Dec, 2007 00:11:06

Message: 3 of 3

On Dec 29, 12:01=A0am, "Huy " <phananh...@mathworks.com> wrote:
> damayi <dam...@gmail.com> wrote in message <a57b1eb8-2471-
>
> 465d-a144-bca8660c3...@l6g2000prm.googlegroups.com>...
>
>
>
>
>
> > Dear all
> > I want to set a group of menu object's 'label' value in
> terms of my
> > requirement.
> > Below is an example code to illustrate my question.
> > % begin
> > LabelCell =3D {'Name'; 'Score'; 'Class'; 'Age'};
> > hm =3D [ 1.111, =A02.222, =A03.333, =A04.444] =A0% all the value is
> a handle to
> > a menu object.
> > for k =3D 1:numel(hm)
> > =A0 =A0 set(hm(k), 'label', LabelCell{k});
> > end
> > % finished
>
> > In this way, I can carry my points. However, I think 'for-
> loop' maybe
> > replaced and I hope that can be realized in a more simple
> way. Any
> > idea about it?
>
> > Best Regards
> > damayi
> > 2007-12-28
>
> arrayfun(@(h,newlab) set(h,'Label',newlab{1}), hm,LabelCell)
>
> Anh Huy Phan
> RIKEN - BSI- Hide quoted text -
>
> - Show quoted text -

Thanks for your help. your solution is so simple.
Meanwhile, I compare two solutions and I found that the former is more
efficient or less time cost.
tic; run1 toc; tic; run2; toc

Elapsed time is 0.001227 seconds.
Elapsed time is 0.002984 seconds.

Tags for this Thread

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.

rssFeed for this Thread

Public Submission Policy

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 Disclaimer prior to use.

Contact us at files@mathworks.com