From: saurabh Srivastava on
Dear all
I am using set(uitable,'data',data) command to put the data in table but it will set the data in entire table or in 1st n colomn. What I want to do is replace specific data in a particular column without affecting the other column data. For example there is N*3 data set in table; I want to change the entire data of 3rd column only. How It can be done...?
From: Walter Roberson on
saurabh Srivastava wrote:
> I am using set(uitable,'data',data) command to put the data in table but it will set the data in entire table or in 1st n colomn. What I want to do is replace specific data in a particular column without affecting the other column data.

No Matlab-level mechanism is supplied for that, at least up through 2008b.

It would not surprise me if there was a Java method that could do what you
want, but I have never looked at the Java level of a uitable.
From: Yair Altman on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hrnkd7$j4j$1(a)canopus.cc.umanitoba.ca>...
> saurabh Srivastava wrote:
> > I am using set(uitable,'data',data) command to put the data in table but it will set the data in entire table or in 1st n colomn. What I want to do is replace specific data in a particular column without affecting the other column data.
>
> No Matlab-level mechanism is supplied for that, at least up through 2008b.
>
> It would not surprise me if there was a Java method that could do what you
> want, but I have never looked at the Java level of a uitable.


uitable returns two arguments: a handle to the created table (a com.mathworks.hg.peer.UitablePeer Java object wrapped within a Matlab handle) and an undocumented second optional argument holding a handle to the Matlab GUI container of the created table. These two arguments are exactly the two arguments returned from the javacomponent function.

Note that the table object returned by uitable is not actually a Java object but rather a Matlab handle object that references the Java object. Because of this, I usually call the returned objects mtable, to differentiate it from the underlying Java object, which I call jtable:

mtable = uitable(&#8230;);
jtable = mtable.getTable;
jtable = get(mtable, 'table'); % an alternative method

It is important to understand that mtable, like any Matlab object, uses 1-based indexing, whereas jtable, like any Java object, uses 0-based indexing. So the first column (or row or anything) is 1 in mtable and 0 in jtable. Forgetting this rule is an endless source of bugs&#8230; Having understood this, we can now turn to the question of how to set data in the table:

jtable.setValueAt(myValue,row,col); % row,col start at 0

We can also set the entire data table at once, useful for performance on large data sets:

jtable.getModel.setDataVector(data); % data = java.util.Vector
data = jtable.getModel.getDataVector;

Yair Altman
http://UndocumentedMatlab.com
From: Corey Kelly on
"Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <hroglq$nfm$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <hrnkd7$j4j$1(a)canopus.cc.umanitoba.ca>...
> > saurabh Srivastava wrote:
> > > I am using set(uitable,'data',data) command to put the data in table but it will set the data in entire table or in 1st n colomn. What I want to do is replace specific data in a particular column without affecting the other column data.
> >
> > No Matlab-level mechanism is supplied for that, at least up through 2008b.
> >
> > It would not surprise me if there was a Java method that could do what you
> > want, but I have never looked at the Java level of a uitable.
>
>
> uitable returns two arguments: a handle to the created table (a com.mathworks.hg.peer.UitablePeer Java object wrapped within a Matlab handle) and an undocumented second optional argument holding a handle to the Matlab GUI container of the created table. These two arguments are exactly the two arguments returned from the javacomponent function.
>
> Note that the table object returned by uitable is not actually a Java object but rather a Matlab handle object that references the Java object. Because of this, I usually call the returned objects mtable, to differentiate it from the underlying Java object, which I call jtable:
>
> mtable = uitable(&#8230;);
> jtable = mtable.getTable;
> jtable = get(mtable, 'table'); % an alternative method
>
> It is important to understand that mtable, like any Matlab object, uses 1-based indexing, whereas jtable, like any Java object, uses 0-based indexing. So the first column (or row or anything) is 1 in mtable and 0 in jtable. Forgetting this rule is an endless source of bugs&#8230; Having understood this, we can now turn to the question of how to set data in the table:
>
> jtable.setValueAt(myValue,row,col); % row,col start at 0
>
> We can also set the entire data table at once, useful for performance on large data sets:
>
> jtable.getModel.setDataVector(data); % data = java.util.Vector
> data = jtable.getModel.getDataVector;
>
> Yair Altman
> http://UndocumentedMatlab.com

I'm having a similar problem and would like to make use of jtable. My gui was started in GUIDE, so I don't have an explicit call to uitable() anywhere. I've tried making the following call in the CreateFcn for the uitable:
handles.jtable = hObject.getTable;

but I'm getting the error

??? Attempt to reference field of non-structure array.

How would I get the handle for the uitable?
From: Yair Altman on
"Corey Kelly" <ckelly01(a)uoguelph.ca> wrote in message
> I'm having a similar problem and would like to make use of jtable. My gui was started in GUIDE, so I don't have an explicit call to uitable() anywhere. I've tried making the following call in the CreateFcn for the uitable:
> handles.jtable = hObject.getTable;
>
> but I'm getting the error
>
> ??? Attempt to reference field of non-structure array.
>
> How would I get the handle for the uitable?

Answered here:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/284435#753987

Yair Altman
http://UndocumentedMatlab.com