Documentation

This is machine translation

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

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

j

Imaginary unit

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.

example

z = a + bj returns a complex numerical constant, z.

example

z = x + 1j*y returns a complex array, z.

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.

z = 1+2j
z =

   1.0000 + 2.0000i

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 =

   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 = r*exp(1j*theta)
z =

   2.8284 + 2.8284i

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 mulitdimensional 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 mulitdimensional 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.

More About

collapse all

Tips

  • 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

See Also

| | | |

Introduced before R2006a

Was this topic helpful?