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:
set allchild doesnt work?

Subject: set allchild doesnt work?

From: Vihang Patil

Date: 4 Apr, 2008 11:40:18

Message: 1 of 6

Hello
I have made a gui with a uipanel having 7 checkboxes and 7
static text boxes.

When I issue;
val = get(allchild(handles.uipanel1),'Value');
I get all the value from that uipanel into val which is
<15x1 cell> matrix, the size which I presume to be for 1
uipanel, 7 checkbox and 7 textbox (1 + 7 + 7 = 15).

Now I want to set the same using set command, so I issue
set(allchild(handles.uipanel1),'Value',val);
But I get an error as follows,
??? Error using ==> set
Conversion to double from cell is not possible.

So, where am I going wrong? I havent changed val and its
still the same <15x1 cell> matrix

Regards
Vihang

Subject: set allchild doesnt work?

From: Jos

Date: 4 Apr, 2008 12:55:03

Message: 2 of 6

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<ft5432$hjf$1@fred.mathworks.com>...
> Hello
> I have made a gui with a uipanel having 7 checkboxes and
7
> static text boxes.
>
> When I issue;
> val = get(allchild(handles.uipanel1),'Value');
> I get all the value from that uipanel into val which is
> <15x1 cell> matrix, the size which I presume to be for 1
> uipanel, 7 checkbox and 7 textbox (1 + 7 + 7 = 15).
>
> Now I want to set the same using set command, so I issue
> set(allchild(handles.uipanel1),'Value',val);
> But I get an error as follows,
> ??? Error using ==> set
> Conversion to double from cell is not possible.
>
> So, where am I going wrong? I havent changed val and its
> still the same <15x1 cell> matrix
>
> Regards
> Vihang
>

As it says: SET expects doubles, not cells

If H is the list of handles

H = allchild(handles.uipanel1)
V = get(H,'value') ; % cell array

then do this:

for i=1:numel(H)
  set(H(i),'value',V{i})
end

which is difficult to vectorize efficiently.

hth
Jos
 

Subject: set allchild doesnt work?

From: Yuri Geshelin

Date: 4 Apr, 2008 13:05:03

Message: 3 of 6

Hi,

Just do

set(allchild(handles.uipanel1),'Value',cell2mat(val));

Another tip: make a single call to allchild:

allch = allchild(handles.uipanel1);
val = get(allch,'Value');
.......
set(allch,'Value',cell2mat(val));

Yuri

"Vihang Patil" <vihang_patil@yahoo.com> wrote in message
<ft5432$hjf$1@fred.mathworks.com>...
> Hello
> I have made a gui with a uipanel having 7 checkboxes and
7
> static text boxes.
>
> When I issue;
> val = get(allchild(handles.uipanel1),'Value');
> I get all the value from that uipanel into val which is
> <15x1 cell> matrix, the size which I presume to be for 1
> uipanel, 7 checkbox and 7 textbox (1 + 7 + 7 = 15).
>
> Now I want to set the same using set command, so I issue
> set(allchild(handles.uipanel1),'Value',val);
> But I get an error as follows,
> ??? Error using ==> set
> Conversion to double from cell is not possible.
>
> So, where am I going wrong? I havent changed val and its
> still the same <15x1 cell> matrix
>
> Regards
> Vihang
>

Subject: set allchild doesnt work?

From: Richard Lang

Date: 4 Apr, 2008 13:37:39

Message: 4 of 6

Vihang Patil wrote:
> Hello
> I have made a gui with a uipanel having 7 checkboxes and 7
> static text boxes.
>
> When I issue;
> val = get(allchild(handles.uipanel1),'Value');
> I get all the value from that uipanel into val which is
> <15x1 cell> matrix, the size which I presume to be for 1
> uipanel, 7 checkbox and 7 textbox (1 + 7 + 7 = 15).
>
> Now I want to set the same using set command, so I issue
> set(allchild(handles.uipanel1),'Value',val);
> But I get an error as follows,
> ??? Error using ==> set
> Conversion to double from cell is not possible.
>
> So, where am I going wrong? I havent changed val and its
> still the same <15x1 cell> matrix
>
> Regards
> Vihang
>

Vihang,
In order to set multiple different values on multiple objects, you need
to also specify a cell array for the property name:

set(allchild(handles.uipanel1),{'Value'},val);

More details are in the help for SET.

Richard

Subject: set allchild doesnt work?

From: Jos

Date: 4 Apr, 2008 14:16:02

Message: 5 of 6

"Jos " <DELjos@jasenDEL.nl> wrote in message <ft58f7$qn7
$1@fred.mathworks.com>...
> "Vihang Patil" <vihang_patil@yahoo.com> wrote in message
> <ft5432$hjf$1@fred.mathworks.com>...
> > Hello
> > I have made a gui with a uipanel having 7 checkboxes
and
> 7
> > static text boxes.
> >
> > When I issue;
> > val = get(allchild(handles.uipanel1),'Value');
> > I get all the value from that uipanel into val which is
> > <15x1 cell> matrix, the size which I presume to be for
1
> > uipanel, 7 checkbox and 7 textbox (1 + 7 + 7 = 15).
> >
> > Now I want to set the same using set command, so I issue
> > set(allchild(handles.uipanel1),'Value',val);
> > But I get an error as follows,
> > ??? Error using ==> set
> > Conversion to double from cell is not possible.
> >
> > So, where am I going wrong? I havent changed val and
its
> > still the same <15x1 cell> matrix
> >
> > Regards
> > Vihang
> >
>
> As it says: SET expects doubles, not cells
>
> If H is the list of handles
>
> H = allchild(handles.uipanel1)
> V = get(H,'value') ; % cell array
>
> then do this:
>
> for i=1:numel(H)
> set(H(i),'value',V{i})
> end
>
> which is difficult to vectorize efficiently.
>
> hth
> Jos
>
>

Others in this thread have looked into SET better than I
have.
Jos

Subject: set allchild doesnt work?

From: Vihang Patil

Date: 5 Apr, 2008 14:13:01

Message: 6 of 6

Thank You all for your help

Yuri: cell2 mat did not work for me.

Richard : This is exactly what I wanted. Cheers!!

Jos: Yes, I too was doing the non vectorised way, before I
read Richard's post. That did the job for me

Thanks Guys
Vihang

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