How can I get 3 decimals placeś ine the table?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kamil Tomiak
le 4 Déc 2017
Commenté : Kamil Tomiak
le 5 Déc 2017
Hello, I'm new to matlab but and i want my numbers in the table to be fixed to 3 decimal places(right now i get something like 5,5182 e+6) here is my code
if true
% code
dane = xlsread('dane1.xlsx');
nr=['W1';'W2';'W3'];
A=dane(:,1);
B=dane(:,2);
C=dane(:,3);
D=dane(:,4);
app.UITable.Visible = 'on';
app.UITable.Data = [cellstr(nr) num2cell(A) num2cell(B) num2cell(C) num2cell(D)];
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170623/image.jpeg)
0 commentaires
Réponse acceptée
Nicolas Schmit
le 5 Déc 2017
Set the column type to char, and use sprintf to format the numbers with the desired number of decimal places.
app.UITable.ColumnFormat = {'char'};
app.UITable.Data = {sprintf('%.3e', 1.2345678e-3)};
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Statistics and Machine Learning Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!