round 6,2 up in matlab

You can use the ceil function to round up a number to the nearest integer or to a specified number of decimal places. To round up 6.2 to one decimal place, you can call the ceil function as follows:

ceil(6.2*10)/10
16 chars
2 lines

This multiplies the number by 10, rounds it up to an integer using ceil, and then divides it back by 10 to get the rounded value.

If you want to round up to two decimal places, you can scale by 100 and then divide by 100.

ceil(6.2*100)/100
18 chars
2 lines

This will return 6.20.

related categories

gistlibby LogSnag