How to round a result to two decimal places
2 397 views (last 30 days)
Show older comments
r=10 (4/3)*pi*r^3 Round the result to two decimal places
Accepted Answer
dpb
on 24 Oct 2016
v=(4/3)*pi*r^3;
>> format long g
>> v
v =
4188.79020478639
>> round(v*100)/100
ans =
4188.79
>>
0 Comments
More Answers (3)
Kirby Fears
on 24 Oct 2016
Mo'men,
Check out the round function.
r_rounded = round(r,2); % rounds to 2 decimal places
Hope this helps.
5 Comments
Eleanor Betton
on 11 Nov 2020
You can write to word with the report generator function. I used this for rounding a table to go into this:
M = round(V*100)/100;
C = num2cell(V);
fun = @(x) sprintf('%0.2f', x);
V = cellfun(fun, C, 'UniformOutput',0);
V=array2table(V);
luke
on 29 Sep 2022
myAns = 2 * (-4-[6+3+(7-(1+8))+12]-3)+5
myAns =
-47
Round the result to two decimal places
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!