MATLAB GUI developers often want to have a mini-spreadsheet in their GUI. This can be done with a new widget added to the set of controls available in GUIDE. Now with UITABLE you can add that capability. This video shows how to add a table for display, then makes it editable and adds a callback such that MATLAB code is run whenever a cell in the table is edited. The data is not linked to the variables in the workspace, so this callback shows you how to pull data out of the table whenever it is updated.
Doug, nice post. One thing, though: it occurs to me that you haven’t shown us how to use/share the value of the variable DATA (from the data in the table) outside of the workspace of the cellEditCallback workspace. There are several ways to do it–addressing the ways, and their relative merits, would make a nice follow-up blog!
UITable was undocumented, but available, for some releases in the past.
Some features like this are available, but undocumented, for various reasons. Sometimes they are there so that we can use them in making tools for MATLAB. These features are undocumented because we need the flexibility to change the interface for a while. If you find undocumented features, you need to be aware that the interface can change or be removed in future releases.
As far as access is concerned, the undocumented uitable of old provided cut and paste options from a uicontextmenu but the new version does not. Is that something that will be addressed in future releases?
I have a gui with a uitable that works well when you hit enter after each cell edit, but when you hit tab after editing a cell’s contents, the CellEditCallback is not executed. Is there a fix for this?
My question follows the previous post here. I am trying to edit the cells of a table. It works well if I hit tab after entering data. However, if I choose the contents of a cell by mouse-click-and-drag, and edit it, unless I click in another cell, the CellEditCallback is not called. I tend to edit the last cell, and then directly press a button that processes the data. So, I end up missing the data on the last cell I edit. How can I rectify this?
By the way, I am sincerely grateful for the most educative and helpful posts. I even considered developing GUI, solely due to your videos.
Hi, I have Matlab 7.5.0 (R2007b) and I need to create a table on an interface, but in the GUI doesn’t exist a botton to create it, do I have to install something to obtain that botton in my GUI
I am investigating a way of loading the uitable with data from two variables. One is a 10×12 double however the second is a 12×13 cell. Is this achievable in any way?
You are going to have to decide how you want these odd shaped pieces to fit together. I recommend putting them all into one big cell, then setting that to the data as normal.
Thanks for your advice, i have merged the data into a cell however when i select the cell in Property Inspector - Data, it will not display the cell data. If i choose a double array i have in the Workspace it displays fine!
Do i need to convert the data within the cell to allow uitable to accept it?
Please, i have never used tables before in matlab and i am using matlab R2007b. Il like to know how to create a table. This is how its supposed to work—I have 2 GUI windows, one for collecting user data like name , gender, address etc and the secon GUI window is the one that should contain the table. I will like a case whereby a user inputs his/her personal details in the first GUI and on pressing “update button” from that first GUI window, it gets added to the table of the second GUI. As different other users key in their personal details and clicks on “update button”, that table continues to be populated and updated
Uitables seem like a convenient way to make a customized property inspector for when there are lots of adjustable parameters in the application. This works well when the parameters all have the same format, otherwise to make use of the column formatting & input features we can only make a “transposed” version (side scrolling, not so pretty).
Having row formatting as an option would be nice. Are there any plans for this in future versions - or is there a better way to go about this?
Leave a Reply
About
Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.
So are these tables only numeric, or can we use a mixed type cell array to populate them?
Also I am currently using 7.5 and see that these tables are available but undocumented. It seems like in this version the ‘data’ is a java object.
Doug, nice post. One thing, though: it occurs to me that you haven’t shown us how to use/share the value of the variable DATA (from the data in the table) outside of the workspace of the cellEditCallback workspace. There are several ways to do it–addressing the ways, and their relative merits, would make a nice follow-up blog!
Brett, I agree. Given that the uitable is a new addition to MATLAB it would be great to see more discussion about various access methods.
Harold,
UITable was undocumented, but available, for some releases in the past.
Some features like this are available, but undocumented, for various reasons. Sometimes they are there so that we can use them in making tools for MATLAB. These features are undocumented because we need the flexibility to change the interface for a while. If you find undocumented features, you need to be aware that the interface can change or be removed in future releases.
-Doug
As far as access is concerned, the undocumented uitable of old provided cut and paste options from a uicontextmenu but the new version does not. Is that something that will be addressed in future releases?
Malcolm,
This suggestion has been entered into our internal enhancement request database. Thanks for the suggestion.
Doug
Hello Doug,
I have a gui with a uitable that works well when you hit enter after each cell edit, but when you hit tab after editing a cell’s contents, the CellEditCallback is not executed. Is there a fix for this?
Thanks,
Austin DeHart
Austin,
This is a known issue. I see that it has been fixed in the next release.
Doug
Hey Doug,
My question follows the previous post here. I am trying to edit the cells of a table. It works well if I hit tab after entering data. However, if I choose the contents of a cell by mouse-click-and-drag, and edit it, unless I click in another cell, the CellEditCallback is not called. I tend to edit the last cell, and then directly press a button that processes the data. So, I end up missing the data on the last cell I edit. How can I rectify this?
By the way, I am sincerely grateful for the most educative and helpful posts. I even considered developing GUI, solely due to your videos.
Thank you very much,
Keerthi
Keerthi,
Our developers are aware of that behavior. A change in behavior is likely in an upcoming release.
Doug
Hi, I have Matlab 7.5.0 (R2007b) and I need to create a table on an interface, but in the GUI doesn’t exist a botton to create it, do I have to install something to obtain that botton in my GUI
Thanks.
Hector,
This was a new feature of 2008a. You will need to upgrade to get the functionality.
Doug
Doug,
I am investigating a way of loading the uitable with data from two variables. One is a 10×12 double however the second is a 12×13 cell. Is this achievable in any way?
Many thanks Doug,
Waggy
Waggy,
You are going to have to decide how you want these odd shaped pieces to fit together. I recommend putting them all into one big cell, then setting that to the data as normal.
Doug
Doug,
Thanks for your advice, i have merged the data into a cell however when i select the cell in Property Inspector - Data, it will not display the cell data. If i choose a double array i have in the Workspace it displays fine!
Do i need to convert the data within the cell to allow uitable to accept it?
Thanks Doug,
Waggy
Waggy,
Here is a very simple example:
t = uitable(’Data’,{1 2 3; ‘1′ ‘2′ ‘3′})
This is a cell array with strings and numerics. It works fine.
Doug
Hello,
Please, i have never used tables before in matlab and i am using matlab R2007b. Il like to know how to create a table. This is how its supposed to work—I have 2 GUI windows, one for collecting user data like name , gender, address etc and the secon GUI window is the one that should contain the table. I will like a case whereby a user inputs his/her personal details in the first GUI and on pressing “update button” from that first GUI window, it gets added to the table of the second GUI. As different other users key in their personal details and clicks on “update button”, that table continues to be populated and updated
Rossonera,
http://blinkdagger.com/matlab/matlab-gui-tutorial-uitable-part-1-how-to-display-data
This might help you!
Doug
Doug,
Thanks for the very helpful videos!
Uitables seem like a convenient way to make a customized property inspector for when there are lots of adjustable parameters in the application. This works well when the parameters all have the same format, otherwise to make use of the column formatting & input features we can only make a “transposed” version (side scrolling, not so pretty).
Having row formatting as an option would be nice. Are there any plans for this in future versions - or is there a better way to go about this?