I got the set command to work. Now I'm having trouble figuring out how to change the data in the table only 2 cells at a time. For example the table is 2x10. When the user clicks a button, I only want data in cells (1,1) and (2,1). Then when they push the button a second time, I want to read the table values that are already there but then add in cells (2,1) and (2,2). Do you have any suggestions for this? I'm having trouble figuring out which cells already have data using the getappdata command.
Setting Data in a GUI Table
31 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
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.
採用された回答
Brendan Hamm
2015 年 3 月 5 日
Use the set command:
f = figure;
d = randn(10,3); % Make some random data to add
t = uitable(f);
set(t,'Data',d); % Use the set command to change the uitable properties.
set(t,'ColumnName',{'a';'b';'c'})
3 件のコメント
Brendan Hamm
2016 年 12 月 11 日
Glad to hear this helped out. I'm a bit surprised to see how many views this one answer has ... must be a popular topic.
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!