round up in matlab

The ceil() function in MATLAB can be used to round up a number to the nearest integer or to a certain number of decimal points. Here's an example:

main.m
x = 6.78;
y = ceil(x); % rounds up to nearest integer
z = ceil(x*10)/10; % rounds up to one decimal place
106 chars
4 lines

The variable y will be equal to 7, while z will be equal to 6.8. The ceil() function can be used on both positive and negative numbers.

related categories

gistlibby LogSnag