FreeMat: REAL Real Function

FreeMat

- Main Page
- Related Pages

REAL Real Function

Section: Elementary Functions

# Usage

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

       y = real(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 real part is a floating point array, so that the return type is `float`. For `dcomplex` inputs, the real part is a double precision floating point array, so that the return type is `double`. The `real` function does nothing to real and integer types.

# Example

The following demonstrates the `real` applied to a complex scalar.

    --> real(3+4*i)

    ans =
     3

The `real` function has no effect on real arguments:

    --> real([2,3,4])

    ans =
     2 3 4

For a double-precision complex array,

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

    ans =
     2 0