This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Imaginary part of complex number




imag(z) returns the imaginary part of z.

imag(A) returns the imaginary part of each element of A.

Input Arguments


Symbolic number, variable, or expression.


Vector or matrix of symbolic numbers, variables, or expressions.


Find the imaginary parts of these numbers. Because these numbers are not symbolic objects, you get floating-point results.

[imag(2 + 3/2*i), imag(sin(5*i)), imag(2*exp(1 + i))]
ans =
    1.5000   74.2032    4.5747

Compute the imaginary parts of the numbers converted to symbolic objects:

[imag(sym(2) + 3/2*i), imag(4/(sym(1) + 3*i)),  imag(sin(sym(5)*i))]
ans =
[ 3/2, -6/5, sinh(5)]

Compute the imaginary part of this symbolic expression:

imag(2*exp(1 + sym(i)))
ans =

In general, imag cannot extract the entire imaginary parts from symbolic expressions containing variables. However, imag can rewrite and sometimes simplify the input expression:

syms a x y
imag(a + 2)
imag(x + y*i)
ans =
ans =
imag(x) + real(y)

If you assign numeric values to these variables or if you specify that these variables are real, imag can extract the imaginary part of the expression:

syms a
 a = 5 + 3*i;
imag(a + 2)
ans =
syms x y real
imag(x + y*i)
ans =

Clear the assumption that x and y are real:

syms x y clear

Find the imaginary parts of the elements of matrix A:

syms x
A = [-1 + sym(i), sinh(x); exp(10 + sym(7)*i), exp(sym(pi)*i)];
ans =
[              1, imag(sinh(x))]
[ exp(10)*sin(7),             0]


You can compute the imaginary part of z via the conjugate: imag(z)= (z - conj(z))/2i.

More About

collapse all


  • Calling imag for a number that is not a symbolic object invokes the MATLAB® imag function.

See Also

| | | |

Introduced before R2006a

Was this topic helpful?