fix(x), round(x),int32(x), and ceil(x), where x=2.2 in matlab

main.m
x = 2.2;
fixed_x = fix(x);
rounded_x = round(x);
int32_x = int32(x);
ceiled_x = ceil(x);
89 chars
6 lines

The fix function returns the largest integer that is less than or equal to x, so fixed_x will be 2.

The round function rounds x to the nearest integer, so rounded_x will also be 2.

The int32 function converts x to a signed 32-bit integer, so int32_x will be 2 as well.

The ceil function returns the smallest integer that is greater than or equal to x, so ceiled_x will be 3.

related categories

gistlibby LogSnag