Set decimal place for uitable
Mostra commenti meno recenti
Hello there,
I have a mat table and I want to present one of the column of such table (the data column) in one decimal place of scientific format in UIFIGURE table (example: 0.00001 should be 1.0e-5). But, my code so far present it as 0.0000. Please find attached the data.
load('data_decimal.mat');
uitable(uifigure,'Data',results{:,:},'ColumnName',results.Properties.VariableNames); % this line gives 0.0000
Thanks!
Risposta accettata
Più risposte (2)
Cris LaPierre
il 12 Nov 2024
fig = uifigure;
uit = uitable(fig,"Data",randi(100,10,3));
uit.Data(1,1) = 0.00001
uit.ColumnFormat = {'shortE'}
3 Commenti
Adi Purwandana
il 12 Nov 2024
Modificato: Adi Purwandana
il 12 Nov 2024
Cris LaPierre
il 12 Nov 2024
Specify a format for each column
uit.ColumnFormat = {[],'shortE'}
Adi Purwandana
il 12 Nov 2024
Mr. Pavl M.
il 12 Nov 2024
Select any format your wish:
%in older Matlab versions format('shortE')
load( 'data_decimal.mat' );
uitable(uifigure, 'Data' ,round(results{:,:},1), 'ColumnName' ,results.Properties.VariableNames); %
%or
format('shortE')
load( 'data_decimal.mat' );
uitable(uifigure, 'Data' ,fix(results{:,:}*10)/10, 'ColumnName' ,results.Properties.VariableNames); %
2 Commenti
Adi Purwandana
il 12 Nov 2024
Mr. Pavl M.
il 13 Nov 2024
Modificato: Mr. Pavl M.
il 13 Nov 2024
Right, you are as usual of course right Adi.
- Have you found how to re-format per column (each column in different format, for example x column in standard numeric, and data column in short scientific?
Because so far they proposed format for whole table, right?:
uit=uitable(uifigure, 'Data' ,results{:,:}, 'ColumnName' ,results.Properties.VariableNames);
uit.ColumnFormat = { 'shortE' };
Whether compose and string pre-printing with C style formating, like '%.1fe%d' and than putting formatted strings to the ui table works better in your specific case than formatting each column by specifiying as per 'shortE'?
Of course in real world and in real time all comes not ideal, while optimality can be achieved with patience and hard work.
Analysis:
How can we add more value to your project and posts, can we make it for CNC, 3D printer machines (also to combine with your previous question on specific distances between 2 tables, like distance for CNC Hybdrid manufacturing, Swiss-type Lathe machining and another distance metric for logistics industries)? For example to find some more simple machining by specially preprocessed tables run instead of complex code?
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
