round two decimal in table app designer
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
[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 Kommentare
Akzeptierte Antwort
Voss
am 4 Aug. 2023
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 Kommentare
Voss
am 5 Aug. 2023
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!