MATLAB Answers

0

Round number to just 2 decimals cases

Asked by Tiago Dias on 7 Dec 2018
Latest activity Commented on by Tiago Dias on 7 Dec 2018
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

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by madhan ravi
on 7 Dec 2018
 Accepted Answer

A = [47.1847 18.78417 8.7849 3.3514];
result=fix(A*100)./100

  3 Comments

for me it gives me this:
result =
47.1800
18.7800
8.7800
3.3500
ok so ? then try
result=sprintf('%.2f',result) % try this at the end
I want without the zeros, since it is for ploting, I dont want the zeros to appear in the annotation i am making

Sign in to comment.