Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the specific usage of round function in matlab?
What is the specific usage of round function in matlab?
Circular function

Function: rounding.

Usage: B = round(A)

Take the integer part of each element in array A in the nearest direction and return the integer array B with the same dimension as A. For a complex parameter A, take the integer part of its real part and imaginary number in the nearest direction and return a complex data B. ..

Example:

Ceil(x) returns the smallest integer value not less than x (then converted to double).

Floor(x) returns the largest integer value not greater than X.

Round(x) returns the rounded integer value of x.

# include & ltstdio.h & gt

# include & ltmath.h & gt

int main(int argc,const char *argv[])

{

Floating point number =1.4999;

printf("ceil(%f) is %f\n ",num,ceil(num));

printf("floor(%f) is %f\n ",num,floor(num));

printf("round(%f) is %f\n ",num,round(num));

Returns 0;

}

Compile: $cc test.c -lm

Execution: $. /a.out

The upper limit (1.499900) is 2.000000.

Floor (1.499900) is 1.000000.

Rounding (1.499900) is equal to 1.000000.

Round () in Matlab

Application example:

a = [- 1.9,-0.2,3.4,5.6,7.0,2.4+3.6i]

a =

Column 1 to 4

- 1.9000 -0.2000 3.4000 5.6000

Columns 5 to 6

7.0000 2.4000 + 3.6000i

Circle (a)

ans =

Column 1 to 4

-2.0000 0 3.0000 6.0000

Columns 5 to 6

7.0000 2.0000 + 4.0000i