Doug's MATLAB Video Tutorials

January 29th, 2009

Exploring uitable properties

I got a question via e-mail that was asking how to set the data in a uitable. Setting the data in a uitable is as easy as: >> a = uitable >> set(a,’data’, magic(3)) The important part of this video is seeing the thought process of discovering that. When you programmatically create a uicontrol, or uitable, you should capture the handle to that widget, as I did with a. When you have that handle you can GET or SET the properties of the widget.

Download the files here.

9 Responses to “Exploring uitable properties”

  1. Geoff replied on :

    Good to have you back here, Doug. As you know, the MATLAB GUI Building doc now links to your archive, so keeps these tips and tricks coming!

    Was this posting inspired by a user who had to ask how to get data into a uitable, even after checking the doc? If so, the MATLAB Graphics and GBT doc has utterly failed to communicate basic information.

  2. Andrew replied on :

    Is this supposed to perform the same on R2007a running on Mac OSX?

    This is what I get when I try to do the same things:

    
    EDU>> close all
    EDU>> clear all
    EDU>> a = uitable
    
    a =
    
    	javahandle_withcallbacks.com.mathworks.hg.peer.UitablePeer
    
    EDU>> set(a,'data',magic(3))
    ??? Object belongs to an incompatible Java class.
    
    EDU>>
    
  3. Andrew replied on :

    In case anyone else found the same issue…
    I went ahead and upgraded to R2008b (ver 7.7.0) and it works exactly as shown in the video. (Running on an Intel-Mac OSX)

    These video tutorials are really helpful! Thanks Doug!
    I am going to get a lot of use out of the uitable in the gui I’m writing.

  4. dhull replied on :

    Andrew,

    Glad you were able to solve your own issue and help everyone else out in the same way.

    Thanks,
    Doug

  5. Sharon replied on :

    Hi, may I know is it possible and how to arrange data in GUI table? I have few variables like a, b, c and d. Each of them have 10 rows of data. I wish to arrange them in the table format in GUI and make it a table of 4 column (a, b, c, d) and 10 rows in GUI. I try to use the command like set(handles.uitable1,’data’,a) and it can display 10 rows in first column of GUI table. But I fail to make it displays b in second column, c in third and d in fourth column. It seems like only can display one column. Thanks a lot.

  6. dhull replied on :

    @Sharon,

    Make the entire matrix of data first then set it into the uitable.

    Doug

  7. ashok replied on :

    how to prepare uitable to incrementally insert data into it.
    like if i have data comming in serial port and i need to display in uitable, one row for each input data segment
    how can i do that??
    i even dont know how many number of rows i need to show at first..
    what is the limit to for row and column in uitable??

    thx n regards
    ash

  8. dhull replied on :

    @Ashok,

    See answer 6 above. You will have to just keep updating it as you see fit.

    Doug

  9. Vincent replied on :

    @Andrew

    I had the same issue a little while ago but on a windows xp with the R2007b, so I tcheck up and finaly see that it was because in this release the uitable function was not completly set and was powered by java, so in the subsequent version they improve it and drop the java part

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.