complex

Construct complex fi object from real and imaginary parts

Syntax

c = complex(a,b)
c = complex(a)
c = complex(a)

Description

The complex function constructs a complex fi object from real and imaginary parts.

c = complex(a,b) returns the complex result a + bi, where a and b are identically sized real N-D arrays, matrices, or scalars of the same data type. When b is all zero, c is complex with an all-zero imaginary part. This is in contrast to the addition of a + 0i, which returns a strictly real result.

c = complex(a) for a real fi object a returns the complex result a + bi with real part a and an all-zero imaginary part. Even though its imaginary part is all zero, c is complex.

c = complex(a) returns the complex equivalent of a, such that isreal(c) returns logical 0 (false). If a is real, then c is a + 0i. If a is complex, then c is identical to a.

The output fi object c has the same numerictype and fimath properties as the input fi object a.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a