j - Imaginary unit - MATLAB (original) (raw)

Syntax

Description

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.

[z](#bt5bq99-1-z) = [a](#bt5bq99-1-a) + [b](#bt5bq99-1-b)j returns a complex numerical constant, z.

example

[z](#bt5bq99-1-z) = [x](#bt5bq99-1-x) + 1j*[y](#bt5bq99-1-y) returns a complex array, z.

example

Examples

collapse all

Create a complex scalar and use the character, j, without a multiplication sign as a suffix in forming a complex numerical constant.

Create a complex vector from two 4-by-1 vectors of real numbers. z is a 4-by-1 complex vector.

x = [1:4]'; y = [8:-2:2]';

z = x+1j*y

z = 4×1 complex

1.0000 + 8.0000i 2.0000 + 6.0000i 3.0000 + 4.0000i 4.0000 + 2.0000i

Create a complex scalar representing a complex vector with radius, r, and angle from the origin, theta.

r = 4; theta = pi/4;

z = rexp(1jtheta)

Input Arguments

collapse all

Real component of a complex scalar, specified as a scalar.

Data Types: single | double

Imaginary component of a complex scalar, specified as a scalar.

If b is double, you can use the character, j, without a multiplication sign as a suffix in forming the complex numerical constant.

Example: 7j

If b is single, you must use a multiplication sign when forming the complex numerical constant.

Example: single(7)*j

Data Types: single | double

Real component of a complex array, specified as a scalar, vector, matrix, or multidimensional array.

The size of x must match the size of y, unless one is a scalar. If either x or y is a scalar, MATLAB® expands the scalar to match the size of the other input.

single can combine with double.

Data Types: single | double

Imaginary component of a complex array, specified as a scalar, vector, matrix, or multidimensional array.

The size of x must match the size of y, unless one is a scalar. If either x or y is a scalar, MATLAB expands the scalar to match the size of the other input.

single can combine with double.

Data Types: single | double

Output Arguments

collapse all

Complex array, returned as a scalar, vector, matrix, or multidimensional array.

The size of z is the same as the input arguments.

z is single if at least one input argument is single. Otherwise, z is double.

Tips

Extended Capabilities

Version History

Introduced before R2006a