how to use a uitable to add two numbers

2 ビュー (過去 30 日間)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2014 年 3 月 28 日
コメント済み: Azzi Abdelmalek 2014 年 3 月 29 日
i have two input variable a and b.. my code is c=a+b. how to represent this in uitable

採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 28 日
Sivakumaran, does this do the trick?
f = figure('Position',[200 200 350 150]);
a = 2; b = 4;
dat = [a b a+b];
cnames = {'a','b','c = a+b'};
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
'Position',[20 20 310 100]);

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 28 日
figure('position',[100 100 400 150])
a=1;
b=2;
c=a+b;
data={a b c};
headers={'a','b','c=a+b'};
h = uitable('Data',data, 'ColumnEditable',true, ...
'ColumnName',headers, 'RowName',[], ...
'ColumnFormat',{'numeric','numeric','numeric'}, ...
'ColumnWidth','auto', ...
'Units','norm', 'Position',[0,0.25,0.65,.45]);
  3 件のコメント
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2014 年 3 月 29 日
how to insert another row? i need to use 10 rows
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 29 日
figure('position',[100 100 400 450])
a=[1 2;3 4;5 6;7 8]; % 4x2 array
data=[a sum(a,2)] % 4x3 array
headers={'a','b','c=a+b'};
h = uitable('Data',data,'ColumnName',headers,'Units','norm', 'Position',[0,0.25,0.65,.65]);

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by