Y = round(X) rounds
each element of X to the nearest integer. If an
element is exactly between two integers, the round function
rounds away from zero to the integer with larger magnitude.

Y = round(X,N,type) specifies
the type of rounding. Specify 'significant' to
round to N significant digits (counted from the
leftmost digit). In this case, N must be a positive
integer.

The format command controls how MATLAB^{®} displays
numbers at the command line. If a number has extra digits that cannot
be displayed in the current format, then MATLAB automatically
rounds the number for display purposes. This can lead to unexpected
results when combined with the round function.

Consider the result of the following subtraction operation,
which displays 5 digits.

format short
x = 112.05 - 110

x =
2.0500

Based on the displayed value of x,
rounding x to 1 decimal should return 2.1.

round(x,1)

ans =
2

In fact, the problem here is that MATLAB is rounding x to
5 digits for display purposes. The round function
returns the correct answer. Confirm the answer by viewing x with format
long, which displays x rounded to 15
digits.

Rounding type, specified as 'decimals' or 'significant'.
The rounding type determines whether round considers
digits in relation to the decimal point or the overall number of significant
digits. N must be a positive integer when you specify 'significant'.
In that case, the round function rounds to the
nearest number with N significant digits.

The default value is 'decimals', so that round(X,N,'decimals') is
equivalent to round(X,N).

Example: round(3132,2,'significant') returns 3100,
which is the closest number to 3132 that has 2 significant
digits.

format short and format
long both display rounded numbers. This can cause unexpected
results when combined with the round function.

For display purposes, use sprintf to
control the exact display of a number as a string. For example, to
display exactly 2 decimal digits of pi (and no
trailing zeros), use sprintf(%.2f,pi).