real
Real part of a complex number.
Category: Mathematics > Elementary Math
Syntax
Y = real(Z)
Returns the real part of each element of Z.
Description
For z = a + b*i, real(z) is a. The function is also a convenient way to discard the tiny imaginary parts that rounding can leave in a result that should be real, for instance the eigenvalues of a symmetric matrix computed by a roundabout route. Do this only when the leftover imaginary part is really negligible.
The class of integer input is preserved.
Input arguments
Z- Numeric array, real or complex.
Output arguments
Y- Real array of the same size as
Z. A real input is returned unchanged.
Example
Real part of complex values
real([1+2i 3 -4i])
real(3+4i)
real(int8(4))
Output
ans = 1×3
1 3 0
ans = 3
ans = int8
4