uitable on cell array containing strings

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply youfellow5575 (51) 12/4/2007 7:32:36 PM

See related articles to this posting

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
Reply youfellow5575 (51) 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
Reply stuartm (471) 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
Reply youfellow5575 (51) 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
Reply 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
Reply titibondat (2) 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
Reply ronmoore1 7/9/2009 9:45:18 PM
comp.soft-sys.matlab 201246 articles. 513 followers. Post

6 Replies
169 Views

Similar Articles

[PageSpeed] 38

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Writing a cell array containing strings and numbers to file
Hello, it should be an easy task, but I can't find a way to do it: I have a cell array 1 by M. Each of the M cells looks approximately like this: string [] [] [] number number string string number number string string .. . . . but with number of rows. All I want is a text file, containing all M cells seperated by an empty row: string [] [] [] number number string string number number string string string [] [] [] number number string string number number string string .. .. .. and so on. How can I achieve this, since dlmwrite refuses to deal with these kind of string arrays? T...

convert to cell array into a character array or cell array of strings
Hi I have this horizontal array of names: Name Size Bytes Class Attributes itemNames 1x70 7428 cell I need to convert this into a a character array or cell array of strings. I tried: S = char( itemNames) ??? Error using ==> char Cell elements must be character arrays. I tried also: S = cellstr( itemNames) ??? Error using ==> cellstr at 34 Input must be a string. I appreciate your help, thanks, Manal "Manal " <news@mathworks.com> wrote in message <guqdbh$qci$1@fred.mathworks.com>... &...

Cell arrays containing cell arrays
Hi Everyone, I have data in cell arrays containing cell arrays. I would like to extract data from these cell arrays and store in a normal array. I am able to do it for a particular case using nested for loops. But I would like to generalize this problem such that I can extract any kind of cell array containing cell arrays just like cell2mat function does. Please let me know if there is any solution to this problem. Thanks, Anil Palaparthi. Already discussed here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/253738 Bruno Anil Kumar Palaparthi wrote: > I ha...

Processing Cell Array of Cell Array of Strings
Hi, So I have a cell array of a cell array of strings that I am working with. As an example consider the following: test=cell(5,1); test{1,1}{1}=num2str(1); test{1,1}{2}=num2str(0); test{2,1}{1}=num2str(0); test{2,1}{2}=num2str(0); test{3,1}{1}=num2str(1); test{3,1}{2}=num2str(1); test{4,1}{1}=num2str(0); test{4,1}{2}=num2str(0); test{4,1}{3}=num2str(0); test{5,1}{1}=num2str(0); test{5,1}{2}=num2str(1); test{5,1}{3}=num2str(0); I want to process this cell array of cell array of strings so that the inside cell array is removed to make it easier to analyze and look at the...

Converting cell array of strings to cell array of numbers
I have x = Columns 1 through 11 '1' '10' '11' '12' '13' '14' '15' '16' '2' '3' '4' Columns 12 through 22 '5' '6' '7' '8' '9' '1' '10' '11' '12' '13' '14' Columns 23 through 33 '15' '16' '2' '3' '4' '5' '6' '7' '8' '9' '1' Co...

Concatenate cell array of strings to a cell vector of strings horizontally
I am facing a problem like: I have a variable cell array (n,m) of strings e.g.: C= 'ab' 'egh' 'zgr',..... 'hlk' 'd' 'zg',.... ....... ...... the result shoud be: D= 'abeghzgr.....' 'hlkdzg....' ....... ...... to me, shoud be 'horzcat',like D=horzcat(C). But does not work. Please post only a solution without loops thx John Ulrich wrote: .... > I have a variable cell array (n,m) of strings e.g.: > C= 'ab' 'egh' 'zgr',..... > ...... >...

Converting a cell array of strings to a char array for use with Java Strings
Hi, I am trying to call a Java function that takes a java.lang.String using a Matlab cell array which has been converted to a char array but it doesn't work. a_cell = { 'This is the first line. ' char(10) ' the second line...' }; a_char = char(a_cell); jString2 = java.lang.String(a_char) % >>> Error message: ??? No constructor java.lang.String with matching signature found. Whereas this works fine: descr = ['This is a test ' 10 ' the second line..']; jString = java.lang.String(descr) What is wrong with that previous char array? Michael I just...

String from a cell array of strings???
Hi there, I have this cell array (3x1): 'John' 'Mike' 'Luke' and I want to get a string like this one: x='John, Mike, Luke' I'm going nuts with all the cell, strings and matrix functions and can't seem to make it. I'm sure it's doable in a single or couple lines. Any help please? Regards, Michael. "Miguel" <migueljaureguizar@gmail.com> wrote in message <gmeo5v$47t$1@fred.mathworks.com>... > Hi there, > > I have this cell array (3x1): > > 'John' > 'Mike' > 'Luke' > &g...

String cell array from string?
Hello, I have the folllowing string: mystring = 'abc,def,gh' I need to transform it in the following cell array: mycell = {'abc','def','gh'} How can I get that cell array? Thanks,GB Hi, try this : mystring = 'abc,def,gh' mycell=strread(mystring,'%s','delimiter',',') J�r�me ...