real

Real part of complex number

Syntax

X = real(Z)

Description

example

X = real(Z) returns the real part of each element in array Z.

Examples

collapse all

Find the real part of the complex number Z.

Z = 2+3i;
X = real(Z)
X = 2

Find the real part of each element in vector Z. The real function acts on Z element-wise.

Z = [0.5i 1+3i -2.2];
X = real(Z)
X = 1×3

         0    1.0000   -2.2000

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. real operates element-wise when Z is nonscalar.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

| | | | |

Introduced before R2006a