How to round a result to two decimal places
조회 수: 1,894(최근 30일)
표시 이전 댓글
r=10 (4/3)*pi*r^3 Round the result to two decimal places
채택된 답변
dpb
2016년 10월 24일
v=(4/3)*pi*r^3;
>> format long g
>> v
v =
4188.79020478639
>> round(v*100)/100
ans =
4188.79
>>
댓글 수: 0
추가 답변(3개)
Kirby Fears
2016년 10월 24일
Mo'men,
Check out the round function.
r_rounded = round(r,2); % rounds to 2 decimal places
Hope this helps.
댓글 수: 5
Eleanor Betton
2020년 11월 11일
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
2022년 9월 29일
myAns = 2 * (-4-[6+3+(7-(1+8))+12]-3)+5
myAns =
-47
Round the result to two decimal places
댓글 수: 0
참고 항목
범주
Find more on Logical in Help Center and File Exchange
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!