## IMAG Imaginary Function

Section: Elementary Functions

### Usage

Returns the imaginary part of the input array for all elements. The general syntax for its use is

       y = imag(x)

where `x` is an `n`-dimensional array of numerical type. The output is the same numerical type as the input, unless the input is `complex` or `dcomplex`. For `complex` inputs, the imaginary part is a floating point array, so that the return type is `float`. For `dcomplex` inputs, the imaginary part is a double precision floating point array, so that the return type is `double`. The `imag` function returns zeros for real and integer types.

### Example

The following demonstrates `imag` applied to a complex scalar.

    --> imag(3+4*i)

    ans =

     4

    -->
    quit

The imaginary part of real and integer arguments is a vector of zeros, the same type and size of the argument.

    --> imag([2,4,5,6])

    ans =

     0 0 0 0

    -->
    quit

For a double-precision complex array,

    --> imag([2.0+3.0*i,i])

    ans =

     3 1

    -->
    quit