Round number to just 2 decimals cases

조회 수: 3 (최근 30일)
Tiago Dias
Tiago Dias 2018년 12월 7일
댓글: Tiago Dias 2018년 12월 7일
Hi,
I want to round A
A = [47.1847 18.78417 8.7849 3.3514]';
B = round(A,2)
C = floor(A*100)/100
so i can get
result = [ 47.18 18.78 8.78 3.35]
but when i use round or floor, i get the 3rd and 4th deciaml cases as 0

채택된 답변

madhan ravi
madhan ravi 2018년 12월 7일
A = [47.1847 18.78417 8.7849 3.3514];
result=fix(A*100)./100
  댓글 수: 3
madhan ravi
madhan ravi 2018년 12월 7일
ok so ? then try
result=sprintf('%.2f',result) % try this at the end
Tiago Dias
Tiago Dias 2018년 12월 7일
I want without the zeros, since it is for ploting, I dont want the zeros to appear in the annotation i am making

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by