round two decimal in table app designer
25 次查看(过去 30 天)
显示 更早的评论
[app.UITableFilteredTable.Data]=Table_HistoricalTable_Struct(app.Eq);
x = [{90} repmat({60},1,size(app.UITableFilteredTable.Data,2)-1)];
app.UITableFilteredTable.ColumnWidth =x;
app.UITableFilteredTable.ColumnName ={};
i try to use : round(v*100)/100 in table field's but it doesn't work
0 个评论
采纳的回答
Voss
2023-8-4
A random matrix:
M = rand(10,2);
A uitable showing that matrix (defaults to 4 decimal places):
figure()
uitable('Data',M);
Another uitable with the numbers rounded to two decimal places:
figure()
uitable('Data',round(M,2));
Another uitable with rounded data, using character vectors instead of numbers:
figure()
t = uitable('Data',compose('%.2f',M),'ColumnFormat',{'char','char'});
Since you are using a uifigure, you can also add a uistyle to the uitable that sets the HorizontalAlignment of the text to the right.
s = uistyle('HorizontalAlignment','right');
addStyle(t,s)
6 个评论
Voss
2023-8-5
Yes
t = app.UITableFilteredTable; % your uitable
s = uistyle('HorizontalAlignment','center') % 'center' or whatever you want them to be
addStyle(t,s,'column',[1 3:size(t.Data,2)]) % add style s to columns 1 and 3:end of uitable t
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!