Setting Data in a GUI Table
显示 更早的评论
Hi,
I've created a GUI in Matlab with 4 pushbuttons and a table. I want to set initial values in the table when the GUI opens, and then change the values in the table when one of the buttons is pressed.
I'm new to this, what do I need to do to set the data in my uiTable1? I feel like this should be easier then I'm making it. I don't want the user to be able to change the cells of the table, I just want to change the cells of the results from a code that I will run as a display.
Thanks,
5 个评论
Patrick
2015-3-5
Brendan Hamm
2015-3-5
Get the old values using the get command, concatenate them together and then set them again:
newVals = randn(1,2);
oldVals = get(t,'Data');
newVals = [oldVals ; newVals];
set(t,'Data',newVals);
Patrick
2015-3-5
Brendan Hamm
2015-3-5
Sure just place this in an if statement (checking the size of the 'Data'), make a new figure, and add a uitable or annotation('textbox',...) with the data.
采纳的回答
更多回答(1 个)
t = handles.uitable1;
d = randn(10,3); % Make some random data to add
set(t,'Data',d); % Use the set command to change the uitable properties.
set(t,'ColumnName',{'a';'b';'c'})
%yingcai1012@hotmail.com
类别
在 帮助中心 和 File Exchange 中查找有关 Programming Utilities 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!