imag
Imaginary part of a complex number.
Category: Mathematics > Elementary Math
Syntax
Y = imag(Z)
Returns the imaginary part of each element of Z.
Description
For z = a + b*i, imag(z) is b. Together with real it splits a complex array into two real arrays, and complex(real(z), imag(z)) rebuilds it.
The imaginary part of the complex conjugate is the negative: imag(conj(z)) == -imag(z).
Input arguments
Z- Numeric array, real or complex.
Output arguments
Y- Real array of the same size as
Z. It is zero for every real element.
Example
Splitting a complex vector
z = [1+2i, 3, 4-5i];
imag(z)
real(z)
imag(7)
Output
ans = 1×3
2 0 -5
ans = 1×3
1 3 4
ans = 0