Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Imaginary unit

`1j`

`z = a + bj`

```
z = x +
1j*y
```

`1j`

returns the basic imaginary unit. `j`

is
equivalent to `sqrt(-1)`

.

You can use `j`

to enter complex numbers.
You also can use the character `i`

as the imaginary
unit. To create a complex number without using `i`

and `j`

,
use the `complex`

function.

For speed and improved robustness in complex arithmetic, use

`1i`

and`1j`

instead of`i`

and`j`

.Since

`j`

is a function, it can be overridden and used as a variable. However, it is best to avoid using`i`

and`j`

for variable names if you intend to use them in complex arithmetic.Use the

`complex`

function to create a complex output in the following cases:When the names

`i`

and`j`

might be used for other variables (and do not equal`sqrt(-1)`

)When the inputs are not

`double`

or`single`

When the imaginary component is all zeros