uitable on cell array containing strings

Recently I have great frustration using the "undocumented"
uitable functionality. Although it works fine with numerical
matrix, it doesn't work with cell array, e.g.,

Matlab command
t = uitable({'a', 'b'}, {'col_1', 'col_2'})
behaves as expected. It creates a table with 2 columns and
two table entries. 

However, subsequently:
set(t, 'Data', {'c', 'd'})
generates an error: "??? Object belongs to an incompatible
Java class."

Could someone shine some light on this? Thank you,
0
12/4/2007 7:32:36 PM
comp.soft-sys.matlab 209998 articles. 11 followers. lunamoonmoon (258) is leader. Post Follow

6 Replies
442 Views

Similar Articles

[PageSpeed] 9

Well, I figured out myself.  Remembering what Yair said last
time, I dig into the code, and found that I have to use 
"t.setData()" instead of "set" to update the table content.

"Stephane Carlier" <youfellow@hotmail.com> wrote in message
<fj4a0k$1v$1@fred.mathworks.com>...
> Recently I have great frustration using the "undocumented"
> uitable functionality. Although it works fine with numerical
> matrix, it doesn't work with cell array, e.g.,
> 
> Matlab command
> t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> behaves as expected. It creates a table with 2 columns and
> two table entries. 
> 
> However, subsequently:
> set(t, 'Data', {'c', 'd'})
> generates an error: "??? Object belongs to an incompatible
> Java class."
> 
> Could someone shine some light on this? Thank you,

0
12/4/2007 7:53:20 PM
This undocumented feature is very difficult to use and its interface will 
probably change soon when it becomes documented. function. You get an error 
because t is a java handle and not a regular HG handle.

Try this:
>>t = uitable({'a', 'b'}, {'col_1', 'col_2'})
>>t.setData({'c', 'd'})

You can look at some usage examples in this application:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16075&objectType=FILE

Stuart

"Stephane Carlier" <youfellow@hotmail.com> wrote in message 
news:fj4a0k$1v$1@fred.mathworks.com...
> Recently I have great frustration using the "undocumented"
> uitable functionality. Although it works fine with numerical
> matrix, it doesn't work with cell array, e.g.,
>
> Matlab command
> t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> behaves as expected. It creates a table with 2 columns and
> two table entries.
>
> However, subsequently:
> set(t, 'Data', {'c', 'd'})
> generates an error: "??? Object belongs to an incompatible
> Java class."
>
> Could someone shine some light on this? Thank you, 


0
stuartm (470)
12/4/2007 11:44:28 PM
Stuart, 

Thank you very much! That helps a lot. I can't wait for the
"documented" uitable because I have to finish the GUI fast
(after all, that's why people use Matlab in the first
place). I just wish them put the feature in asap. 
0
12/5/2007 3:30:04 PM
"Stephane Carlier" <youfellow@hotmail.com> wrote in message
<fj6g5s$svh$1@fred.mathworks.com>...
> Stuart, 
> 
> Thank you very much! That helps a lot. I can't wait for the
> "documented" uitable because I have to finish the GUI fast
> (after all, that's why people use Matlab in the first
> place). I just wish them put the feature in asap. 
 
uitable becomes documented in the upcoming Matlab version
(R2008a, aka 7.6), at least in the beta version. I have
still not investigated the degree to which it became
documented with respect to the underlying Java functionality. 
 
Yair Altman 
http://ymasoftware.com 

0
altmanyDEL (1141)
2/2/2008 4:40:04 PM
"Stuart McGarrity" <stuartm@mathworks.com> wrote in message
<fj4oos$bq8$1@fred.mathworks.com>...
> This undocumented feature is very difficult to use and its
interface will 
> probably change soon when it becomes documented. function.
You get an error 
> because t is a java handle and not a regular HG handle.
> 
> Try this:
> >>t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> >>t.setData({'c', 'd'})
> 
> You can look at some usage examples in this application:
>
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16075&objectType=FILE
> 
> Stuart
> 
> "Stephane Carlier" <youfellow@hotmail.com> wrote in message 
> news:fj4a0k$1v$1@fred.mathworks.com...
> > Recently I have great frustration using the "undocumented"
> > uitable functionality. Although it works fine with numerical
> > matrix, it doesn't work with cell array, e.g.,
> >
> > Matlab command
> > t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> > behaves as expected. It creates a table with 2 columns and
> > two table entries.
> >
> > However, subsequently:
> > set(t, 'Data', {'c', 'd'})
> > generates an error: "??? Object belongs to an incompatible
> > Java class."
> >
> > Could someone shine some light on this? Thank you, 
> 
> 


Hello,
i try to update a uitable which contains a basic matrix of
numbers. How can i do it (using the setData i suppose)?
typically, my table t contains matrix Datatable, and i want
to update the table with a new matrix Datatable_updated.
the basic command t.setData(Datable_updated) doesn't work. 
What is the syntax when you want to update a table?
thanks





0
2/21/2008 1:49:02 PM
Thierry,

Did you find a solution to this problem?  I have the same issue trying to set an array.  I can not upgrade to take advantage of the documented version due to project requirements.

Ronnie

"Thierry " <titibondat@hotmail.com> wrote in message <fpjvge$dt5$1@fred.mathworks.com>...
> "Stuart McGarrity" <stuartm@mathworks.com> wrote in message
> <fj4oos$bq8$1@fred.mathworks.com>...
> > This undocumented feature is very difficult to use and its
> interface will 
> > probably change soon when it becomes documented. function.
> You get an error 
> > because t is a java handle and not a regular HG handle.
> > 
> > Try this:
> > >>t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> > >>t.setData({'c', 'd'})
> > 
> > You can look at some usage examples in this application:
> >
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16075&objectType=FILE
> > 
> > Stuart
> > 
> > "Stephane Carlier" <youfellow@hotmail.com> wrote in message 
> > news:fj4a0k$1v$1@fred.mathworks.com...
> > > Recently I have great frustration using the "undocumented"
> > > uitable functionality. Although it works fine with numerical
> > > matrix, it doesn't work with cell array, e.g.,
> > >
> > > Matlab command
> > > t = uitable({'a', 'b'}, {'col_1', 'col_2'})
> > > behaves as expected. It creates a table with 2 columns and
> > > two table entries.
> > >
> > > However, subsequently:
> > > set(t, 'Data', {'c', 'd'})
> > > generates an error: "??? Object belongs to an incompatible
> > > Java class."
> > >
> > > Could someone shine some light on this? Thank you, 
> > 
> > 
> 
> 
> Hello,
> i try to update a uitable which contains a basic matrix of
> numbers. How can i do it (using the setData i suppose)?
> typically, my table t contains matrix Datatable, and i want
> to update the table with a new matrix Datatable_updated.
> the basic command t.setData(Datable_updated) doesn't work. 
> What is the syntax when you want to update a table?
> thanks
> 
> 
> 
> 
> 
0
ronmoore1 (4)
7/9/2009 9:45:18 PM
Reply: