フィルターのクリア

In matlab uitables, Is it possible to add the data in each row together to get its summation? If so, how can i do it?

2 ビュー (過去 30 日間)
I created the table using guide.
i have a 7x3 table and four each row i would like to add the data in the first 2 columns so that the summation will go in the third column.
I can i program this feature
any suggestions or examples relevant will help
thanks,
Cordelle

採用された回答

Walter Roberson
Walter Roberson 2013 年 7 月 5 日
datacell = get(handles.YourTable, 'Data');
datamatrix = cell2mat(datacell(:,1:end-1));
sums = sum(datamatrix, 2);
sumscell = num2cell(sums);
datacell(:,end) = sumscell;
set(handles.YourTable, 'Data', datacell);
  3 件のコメント
Cordelle
Cordelle 2013 年 7 月 8 日
It seems as if it was adding the ASCII numbers together.
Cordelle
Cordelle 2013 年 7 月 8 日
Nevermind, i fixed it, i used:
result = reshape(str2num(datamatrix(:)), size(datamatrix));
to convert number character array to a number integer array. Once that was done, sums = sum(result,2) worked just fine.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by