How can I get 3 decimals placeś ine the table?

조회 수: 7 (최근 30일)
Kamil Tomiak
Kamil Tomiak 2017년 12월 4일
댓글: Kamil Tomiak 2017년 12월 5일
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)];

채택된 답변

Nicolas Schmit
Nicolas Schmit 2017년 12월 5일
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)};
  댓글 수: 1
Kamil Tomiak
Kamil Tomiak 2017년 12월 5일
well i used insted of e f to get fix number but it helped me! thanks! app.UITable.ColumnFormat = {'char'}; app.UITable.Data = {sprintf('%.3f', 1.2345678e-3)};

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by