how can i display only two decimals in uitable MATLAB?
34 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, i have a table in a subplot having also three histograms. I want to display in the table only two decimals and i don't know how to do it. This is my code:
clear; close all;
load('data')
.....
h = subplot(2,2,4);
hPos = get(h, 'Position');
tt = {'average';'standard dev.'; '% no rebound'};
MAC = [mean_MAC; std_MAC; mean_perc_zero_MAC]; % here
OMT= [mean_OMT; std_OMT; mean_perc_zero_OMT];
ACC = [mean_ACC; std_ACC; mean_perc_zero_ACC];
T = table(MAC,OMT,ACC,'RowNames',tt);
uitable('Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position', hPos);
set(h, 'Visible', 'Off')
0 Commenti
Risposte (2)
dpb
il 12 Lug 2019
Don't have that much flexibility with numeric formattting in the object, sorry.
uitable uses the same setting as the command window for its 'numeric' keyword. You could set the 'ColumnFormat' to the string 'Bank' that does use two decimal places as the easiest workaround.
Seems like reasonable enhancement request; I have no idea how complicated it would be to implement a general formatting facility to set '%.2f', for example, as to whether there would be any chance at all of such being ever implemented.
The alternative is to write a CellEditCallback function and format the data as desired but then display it as character string, not numeric.
0 Commenti
aamir ibrahim
il 26 Feb 2024
Round off the numbers to the desired value. e.g. x = round(x,2) to two decimal places. Convert to string using string(x). This worked for me.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!