フィルターのクリア

How to set data in the same uitable

4 ビュー (過去 30 日間)
yu yue
yu yue 2016 年 10 月 17 日
コメント済み: yu yue 2016 年 10 月 17 日
I have a 3 columns x 6 rows uitable, the user will input data in column 1 & column 2, column 3 will display the result of (column 2 - column 1). My code is:
T_Data = get(handles.t_data, 'data');
t11=T_Data{1,1};
t21=T_Data{2,1};
t31=T_Data{3,1};
t41=T_Data{4,1};
t51=T_Data{5,1};
t61=T_Data{6,1};
t12=T_Data{1,2};
t22=T_Data{2,2};
t32=T_Data{3,2};
t42=T_Data{4,2};
t52=T_Data{5,2};
t62=T_Data{6,2};
Net1= t12-t11;
Net2= t22-t21;
Net3= t32-t31;
Net4= t42-t41;
Net5= t52-t51;
Net6= t62-t61;
set(handles.T_Data{1,3},'data',Net1);
But I get the error:
Cell contents reference from a non-cell array object.
Why?
How can I display the number I wanted in the same uitable?
Thank you.

採用された回答

Adam
Adam 2016 年 10 月 17 日
編集済み: Adam 2016 年 10 月 17 日
You haven't shown how you create your table, but I assume 'Data' is a numeric array, not a cell array.
Why would you create all those ugly variables though instead of just doing maths with the data as they already are in the array?
T_Data(1,3) = T_Data(1,2) - T_Data(1,1);
or simply
T_Data(:,3) = T_Data(:,2) - T_Data(:,1);
to do all at once, then after editing the whole thing just put it back into your table 'Data' property:
set(handles.t_data, 'data', T_Data);

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 10 月 17 日
T_Data may be a cell array if some of the table entries were text/strings. In that case you'd need to use {} to get the contents of the numeric cells:
T_Data{1,3} = T_Data{1,2} - T_Data{1,1};
because using () would refer to actual cells, not the contents of the cells. If T_Data is not a cell, just do it like Adam said.
  1 件のコメント
yu yue
yu yue 2016 年 10 月 17 日
You are right, I need to use{}. Thank you.

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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by