Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounding a decimal number in MATLAB

Tags:

matlab

How can I round a decimal number like 26,548746540516 to 26,5487 in MATLAB?

like image 733
qwe Avatar asked Dec 27 '22 10:12

qwe


1 Answers

You can use round as follows

round(x*10000) / 10000.0

Alternatively, you can use round2

round2(x,0.0001)
round2(x,1e-4) 
like image 105
petrichor Avatar answered Jan 10 '23 01:01

petrichor