Thread Subject: uitable help

Subject: uitable help

From: ben

Date: 2 Sep, 2009 06:20:03

Message: 1 of 7

*I can add a table to my gui by this code:
mytable = uitable;
set(mytable,'Data',magic(10))
set(mytable,'ColumnWidth',{25})

*Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.

But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
set(mytable,'Data',magic(10))

because i don't know the name of the table, it is not "mytable".
Can you help me please?

Subject: uitable help

From: Andy

Date: 2 Sep, 2009 13:10:19

Message: 2 of 7

"ben " <controlusc@gmail.com> wrote in message <h7l2qj$9qs$1@fred.mathworks.com>...
> *I can add a table to my gui by this code:
> mytable = uitable;
> set(mytable,'Data',magic(10))
> set(mytable,'ColumnWidth',{25})
>
> *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
>
> But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> set(mytable,'Data',magic(10))
>
> because i don't know the name of the table, it is not "mytable".
> Can you help me please?

Drag the table into your figure, then right click on it and select "Property Inspector". Change the "tag" field to whatever you want the table to be called.

Subject: uitable help

From: ben

Date: 2 Sep, 2009 18:29:06

Message: 3 of 7

I tried that but It didn't worked.

Tag name of the table is uitable2

when i give command as
set(uitable2,'Data',magic(10))

the error is "??? Undefined function or variable 'uitable2'."

Can you make an example please



"Andy " <theorigamist@gmail.com> wrote in message <h7lqrr$6b5$1@fred.mathworks.com>...
> "ben " <controlusc@gmail.com> wrote in message <h7l2qj$9qs$1@fred.mathworks.com>...
> > *I can add a table to my gui by this code:
> > mytable = uitable;
> > set(mytable,'Data',magic(10))
> > set(mytable,'ColumnWidth',{25})
> >
> > *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
> >
> > But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> > set(mytable,'Data',magic(10))
> >
> > because i don't know the name of the table, it is not "mytable".
> > Can you help me please?
>
> Drag the table into your figure, then right click on it and select "Property Inspector". Change the "tag" field to whatever you want the table to be called.

Subject: uitable help

From: matt dash

Date: 2 Sep, 2009 19:05:23

Message: 4 of 7

"ben " <controlusc@gmail.com> wrote in message <h7mdhi$ftg$1@fred.mathworks.com>...
> I tried that but It didn't worked.
>
> Tag name of the table is uitable2
>
> when i give command as
> set(uitable2,'Data',magic(10))
>
> the error is "??? Undefined function or variable 'uitable2'."
>
> Can you make an example please
>
>
>
> "Andy " <theorigamist@gmail.com> wrote in message <h7lqrr$6b5$1@fred.mathworks.com>...
> > "ben " <controlusc@gmail.com> wrote in message <h7l2qj$9qs$1@fred.mathworks.com>...
> > > *I can add a table to my gui by this code:
> > > mytable = uitable;
> > > set(mytable,'Data',magic(10))
> > > set(mytable,'ColumnWidth',{25})
> > >
> > > *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
> > >
> > > But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> > > set(mytable,'Data',magic(10))
> > >
> > > because i don't know the name of the table, it is not "mytable".
> > > Can you help me please?
> >
> > Drag the table into your figure, then right click on it and select "Property Inspector". Change the "tag" field to whatever you want the table to be called.

no, it will be called handles.uitable2. That's how the tags work.

Subject: uitable help

From: ben

Date: 2 Sep, 2009 19:10:19

Message: 5 of 7

i also tried

set(handles.uitable2,'Data',magic(10))


"ben " <controlusc@gmail.com> wrote in message <h7mdhi$ftg$1@fred.mathworks.com>...
> I tried that but It didn't worked.
>
> Tag name of the table is uitable2
>
> when i give command as
> set(uitable2,'Data',magic(10))
>
> the error is "??? Undefined function or variable 'uitable2'."
>
> Can you make an example please
>
>
>
> "Andy " <theorigamist@gmail.com> wrote in message <h7lqrr$6b5$1@fred.mathworks.com>...
> > "ben " <controlusc@gmail.com> wrote in message <h7l2qj$9qs$1@fred.mathworks.com>...
> > > *I can add a table to my gui by this code:
> > > mytable = uitable;
> > > set(mytable,'Data',magic(10))
> > > set(mytable,'ColumnWidth',{25})
> > >
> > > *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
> > >
> > > But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> > > set(mytable,'Data',magic(10))
> > >
> > > because i don't know the name of the table, it is not "mytable".
> > > Can you help me please?
> >
> > Drag the table into your figure, then right click on it and select "Property Inspector". Change the "tag" field to whatever you want the table to be called.

Subject: uitable help

From: Nathan

Date: 2 Sep, 2009 19:23:31

Message: 6 of 7

On Sep 2, 12:10 pm, "ben " <control...@gmail.com> wrote:
> i also tried
>
> set(handles.uitable2,'Data',magic(10))
>
> "ben " <control...@gmail.com> wrote in message <h7mdhi$ft...@fred.mathworks.com>...
> > I tried that but It didn't worked.
>
> > Tag name of the table is uitable2
>
> > when i give command as
> > set(uitable2,'Data',magic(10))
>
> > the error is "??? Undefined function or variable 'uitable2'."
>
> > Can you make an example please
>
> > "Andy " <theorigam...@gmail.com> wrote in message <h7lqrr$6b...@fred.mathworks.com>...
> > > "ben " <control...@gmail.com> wrote in message <h7l2qj$9q...@fred.mathworks.com>...
> > > > *I can add a table to my gui by this code:
> > > > mytable = uitable;
> > > > set(mytable,'Data',magic(10))
> > > > set(mytable,'ColumnWidth',{25})
>
> > > > *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
>
> > > > But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> > > > set(mytable,'Data',magic(10))
>
> > > > because i don't know the name of the table, it is not "mytable".
> > > > Can you help me please?
>
> > > Drag the table into your figure, then right click on it and select "Property Inspector".  Change the "tag" field to whatever you want the table to be called.
>
>

Where are you trying this?
Did you remember to update the handles?

Normally, if you created (and saved) a uitable in GUIDE, assuming you
changed the tag to 'uitable2', you should be able to access the
information in this uitable through its handles properies:
set(handles.uitable2,'Data',magic(10));

For example, I have this code in a checkbox7 callback. My uitable's
tag is uitable1:

checkbox = get(handles.checkbox7,'Value');
if checkbox
    set(handles.uitable1,'Data',rand(3,2)*10)
else
    set(handles.uitable1,'Data',zeros(size(get
(handles.uitable1,'Data'))))
end

Are you saying that this still doesn't work?
If so: where are you putting this code?
Are you trying to run the GUI and then trying to set the data through
the matlab command prompt?

-Nathan

Subject: uitable help

From: Andy

Date: 2 Sep, 2009 19:28:04

Message: 7 of 7

"ben " <controlusc@gmail.com> wrote in message <h7mfur$mu7$1@fred.mathworks.com>...
> i also tried
>
> set(handles.uitable2,'Data',magic(10))
>
>
> "ben " <controlusc@gmail.com> wrote in message <h7mdhi$ftg$1@fred.mathworks.com>...
> > I tried that but It didn't worked.
> >
> > Tag name of the table is uitable2
> >
> > when i give command as
> > set(uitable2,'Data',magic(10))
> >
> > the error is "??? Undefined function or variable 'uitable2'."
> >
> > Can you make an example please
> >
> >
> >
> > "Andy " <theorigamist@gmail.com> wrote in message <h7lqrr$6b5$1@fred.mathworks.com>...
> > > "ben " <controlusc@gmail.com> wrote in message <h7l2qj$9qs$1@fred.mathworks.com>...
> > > > *I can add a table to my gui by this code:
> > > > mytable = uitable;
> > > > set(mytable,'Data',magic(10))
> > > > set(mytable,'ColumnWidth',{25})
> > > >
> > > > *Or i can add a table by dragging table icon from left frame in GUIDE Layout editor.
> > > >
> > > > But when i add a table with Layout editor, i can't access to it from m file, because i don't know how to manipulate like
> > > > set(mytable,'Data',magic(10))
> > > >
> > > > because i don't know the name of the table, it is not "mytable".
> > > > Can you help me please?
> > >
> > > Drag the table into your figure, then right click on it and select "Property Inspector". Change the "tag" field to whatever you want the table to be called.

Where are you putting this command? I just created a GUI in GUIDE with a table, and set its CreateFcn to the following:

  function uitable1_CreateFcn(hObject, eventdata, handles)
  % hObject handle to uitable1 (see GCBO)
  % eventdata reserved - to be defined in a future version of MATLAB
  % handles empty - handles not created until after all CreateFcns called
  set(hObject,'Data',magic(10));


This worked correctly for me.

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
uitable ben harper 2 Sep, 2009 02:24:05
gui ben harper 2 Sep, 2009 02:24:05
rssFeed for this Thread

Contact us at files@mathworks.com