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.


Real part of complex number




real(z) returns the real part of z.

real(A) returns the real part of each element of A.

Input Arguments


Symbolic number, variable, or expression.


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


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

[real(2 + 3/2*i), real(sin(5*i)), real(2*exp(1 + i))]
ans =
    2.0000         0    2.9374

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

[real(sym(2) + 3/2*i), real(4/(sym(1) + 3*i)),  real(sin(sym(5)*i))]
ans =
[ 2, 2/5, 0]

Compute the real part of this symbolic expression:

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

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

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

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

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

Clear the assumption that x and y are real:

syms x y clear

Find the real 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, real(sinh(x))]
[ cos(7)*exp(10),            -1]


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


You can compute the real part of z via the conjugate: real(z)= (z + conj(z))/2.

See Also

| | | |

Introduced before R2006a

Was this topic helpful?