How to set values of specific data columns in a uitable

19 ビュー (過去 30 日間)
Med Aymane Ahajjam
Med Aymane Ahajjam 2015 年 10 月 13 日
回答済み: Med Aymane Ahajjam 2015 年 10 月 13 日
Hello, I have a gui table of 2 columns and 6 rows. how can I set to desired values, any specific column of my gui table?
i have tried to use : set(handles.traj_tableau,'data',newdata);
with newdata is a 6*1 column matrix, but this only lets me change the 1st columns of the table, I want to change the second one without changing the first one..
Please help this is urgent
  1 件のコメント
Jan
Jan 2015 年 10 月 13 日
Please omit the hashes at the tags. This is not twitter.

サインインしてコメントする。

採用された回答

TastyPastry
TastyPastry 2015 年 10 月 13 日
You need to extract the entire set of data from the uitable, edit it, then set it back as the uitable's data.
tableData = get(handles.myTable,'data');
%manipulate the data here
set(handles.myTable,'data',tableData);

その他の回答 (3 件)

Jae Song
Jae Song 2015 年 10 月 13 日
How about something like this? In the code, the initial data set variable (tdata) is updated using new column data (newdata). Then, using the updated data set, a new UItable is created.
headers1 = {'Column1','Column2'};
rownames1 = {'Row1','Row2','Row3','Row4','Row5','Row6'};
colFormat1 = {'short','short'};
tdata = [2 3; 4 5; 6 1; 1 2; 3 4; 5 6;]; %: init data for table to display
f1 = figure('Name','table1');
hTable1 = uitable('Parent',f1,'Data',tdata,'ColumnName',headers1, 'RowName', rownames1, 'ColumnFormat',colFormat1, 'ColumnWidth','auto');
newdata = [10;20;30;40;50;60]; %: new column data
tdata(:,2) = newdata; %: updated dataset
f2 = figure('Name','table2');
hTable2 = uitable('Parent',f2,'Data',tdata,'ColumnName',headers1, 'RowName', rownames1, 'ColumnFormat',colFormat1, 'ColumnWidth','auto');

Med Aymane Ahajjam
Med Aymane Ahajjam 2015 年 10 月 13 日
i see so i can't manipulate one columns at a time.. Thanks :)

Med Aymane Ahajjam
Med Aymane Ahajjam 2015 年 10 月 13 日
yeah okay, it seems better to use 2 tables other than 1.. Thanks :)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by