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 203626 articles. 536 followers. Post

6 Replies
288 Views

Similar Articles

[PageSpeed] 17


  • 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',..... > ...... >...

Error: cannot support cell arrays containing cell arrays or objects
I created a cell array from an asc file. I want to convert it to a numeric array to make operations easier. I'm getting the error message: cannot support cell arrays containing cell arrays or objects. How can I fix this? Any help would be much appreciated. for p = 1:length(sample); eval(['fid=fopen(''../RawData/' sample(p).name '@' sample(p).acqo '.asc'');']); d = fgetl(fid); % defines d as the first line of the file date = d(end-8:end); % defines date as the 8th character from the end to the end t = fgetl(fid); %defines...

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...

Cell array to string array
Ok if i have a cell array and i want to turn it in to an array of string or anything apart form cell how do I do it? Please help.....cell2mat does not work "Mohit Thukral" wrote in message <ig4ei8$16i$1@fred.mathworks.com>... > Ok if i have a cell array and i want to turn it in to an array of string or anything apart form cell how do I do it? Please help.....cell2mat does not work anyone?? "Mohit Thukral" wrote in message <ig4hrc$5m2$1@fred.mathworks.com>... > "Mohit Thukral" wrote in message <ig4ei8$16i$1@fred.mathworks.com>... &...

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 ...

Numeric array to Cell array of strings
Hi all, I'm trying to write a one-liner to convert an array of numbers to a cell-array of strings, i.e. I have a numeric array such as: >> a = 10:15 a = 10 11 12 13 14 15 I want to write a one-liner to take the above array and produce the following cell-array output: >> c = {'10' '11' '12' '13' '14' '15'} c = '10' '11' '12' '13' '14' '15' I can do this with a loop, but I feel that's cheating. I feel *sure* there must be more elegant way?!?...

Comparing a cell array of strings with a string.
I have the following code Fid=3Dfopen(=91ex.m=92)=20 Out=3Dtextscan(fid, =91%s=92, =91Delimiter, =91\n=92); Out=3Dregexp(out{1}, =91 =91 , =91split=92); Fclose(fid); Comb=3Dunique([out{:}]);=20 M=3Dsize(out,1); Idx=3Dfalse(m,size(comb,2)); %Loop for number of lines (rows) For ii=3D1:m Idx(ii,: ) =3D ismember(comb, out{ii}); End Which does as intended, however, I would like to be able to choose certain= rows only from idx that have say 'string1' in it. I know to use strcmp('st= ring1', out{i}), but when I do so, I still get all of idx, how do I show ...

One string from cell array of strings?
Hello all! I've got a problem I've been working on. I have unspecified amount of cells and I want to make one string from the array.I've made the array (AB) with cells (strings): ab1 -cell 1 , -cell 2 ab2 -cell 3 , -cell 4 .. .. abn -cell n I would like to convert this array to string: ab1,ab2,...,abn -cell 1 which I will input to mintersect (intersect, which accepts multiple inputs). Same_coordinates=mintersect(ab1,ab2,...,abn); I've tried strcat, which will not work because I can't make an input of AB_string=strcat(AB(1,:)); becaus...

RCR: String#contain? and Array#contain?
Every time I have to guess from memory whether to use "contain?" or "include?" within arrays and strings, I always guess wrong (the right answer is only "include?" BTW). Since ruby typically allows multiple ways of doing things, consider this a feature request to add contain? to both String and Array. Any feedbacks to this idea? Thanks. -r -- Posted via http://www.ruby-forum.com/. On Sep 23, 4:32=A0pm, Roger Pack <rogerpack2...@gmail.com> wrote: > Every time I have to guess from memory whether to use "contain?" or > &quo...

How to delete a cell in cell arrays of strings?
Eg. a=[{'aaa'};{'bbb'};{'ccc'}] i can assign the cell such as a{2}='' however, it is still inside the memory, how can i delete the cell completely from my array? I have searched for function like trim, squeeze and deblank, they can only perform on cell of characters but not string, can anyone help me? thanks a lot for helping Hi, a=[{'aaa'};{'bbb'};{'ccc'}] a(2)=[] J�r�me ...

Concat string to cell array of strings
Hi, I'm trying to concat a string to each string in a cell array of strings using: first = 'first_' attach = { 'end' 'end1' 'end31' } i=1:1:size(attach,2) cellfun( @(x) [first x(i) ], attach, 'UniformOutput',false) It works, except that all of the values in attach are truncated to 'end'. How do I prevent that from happening? Thanks! Cathy "CLou " <cathy@prismstoneconsultingTO.com> wrote in message <i0g266$s6s$1@fred.mathworks.com>... > Hi, > > I'm trying to concat a string to each s...

Convert from an array of cells to an array of strings?
I'm trying to output text through fprintf, but the text is saved in an array of cells. How can I covert this data to string format? ...

Finding a string match in a cell array of strings
This should be simple but I just have not seemed crack this simple task. I have a cell array of 850 elements lets say.... intermRowIDs = {850,1} Almost all of the elements are strings like the following with multiple words 'C5N Merged Feed Partial Pressure (psig)' 'C6P Merged Feed Partial Pressure (psig)' 'C6N Merged Feed Partial Pressure (psig)' 'C7P Merged Feed Partial Pressure (psig)' 'C7N Merged Feed Partial Pressure (psig)' 'C8P Merged Feed Partial Pressure (psig)' 'C8N Merged Feed Partial Pr...

Convert numeric array to cell array of strings
Suppose I have a 4x4 numeric array of integers: >> A = magic(4); From A, I would like to create a 4x4 cell array B, in which each element is B{i,j} = num2str(A(i,j)). It is easy to do this with loops: >> for i = 1:2 >> for j = 1:2, >> B{i,j} = num2str(A(i,j)); >> end >> end Is there a good vectorized way to do this? the cyclist wrote: > Suppose I have a 4x4 numeric array of integers: > >>> A = magic(4); > > From A, I would like to create a 4x4 cell array B, in which each > element is B{i,j} = num2str(A(i,j)). > > It is ea...

index & remove cells from a cell array of strings
I located a string in a cell array of strings as follows: k = strfind(cellstr, pattern) ans = [ ] [ ] [ ] [49] [49] [49] [49] [49] [49] [ ] [ ] [49] [ ] [ ] How can I remove the cells (rows) where the string was found ([49])? cellstr (strfind(cellstr, pattern))=[ ] ; cellstr (strfind(cellstr, pattern),:)=[ ] ; Nanette wrote: > > > I located a string in a cell array of strings as follows: > > k = strfind(cellstr, pattern) > > ans = > > [ ] > [ ] > [ ] > [49] > [49] > [49] > [49] > [49]...

Searching two cell arrays of strings for common strings
What I am hoping to do is compare two cell arrays of strings to find if any strings in cell array 1 contain any strings found in cell array 2 without resorting to a loop: cell1 = { 'Bob', 'Sue', 'Tom' } cell2 = { 'Joe', 'Bob', 'Bill' } index = any string from cell1 that contains any string from cell2; answer should be index = 1; -- "All you need in life is ignorance and confidence; then success is sure" -Mark Twain, in a letter (1887) JVSFugitive "JVSFugitive" <notmyreal@address.com> wrote in message news:D7ch...

gettting index corresponding to string in cell array of strings
Sounds simple (and might be simple too): Suppose you have a cell array of strings, like cellArray = {'I' 'want' 'this' 'string'} and now want the index of the string 'this'. Just like the find function returns the index of a specified numeric value. I know there is strfind: strfind(cellArray,'this') ans = [] [] [1] [] But how to get this (really fast, need to do this very often with big cellArrays) to an index? Sounds so easy, but somehow I just can't get it working! Very thankful for any help! Thanx! Erik ...

Finding the position of a specific string in a cell array of strings
I have been trying to figure this out today and it is really bugging me: I have a cell array of strings, let's call is A, like this: A = 'abc' '123' 'def' '456' I want to give a query and find out which cell, if any, has the query string. For example, if I want to find out which cell 'def' is in, I want it to tell me that it is in the third cell. If I use regexp to do this, it gives me an answer like this: regexp(A, 'def') [] [] [1] [] Which is not very helpful to me, because I just want a number back--I don'...