MATLAB Function Reference | ![]() ![]() |
Construct complex data from real and imaginary components
Syntax
c = complex(a,b) c = complex(a)
Description
c = complex(a,b)
creates a complex output, c
, from the two real inputs.
c = a + bi
The output is the same size as the inputs, which must be equally sized vectors, matrices, or multi-dimensional arrays.
The complex
function provides a useful substitute for expressions such as
a + i*b or a + j*b
in cases when the names "i
" and "j
" may be used for other variables (and do not equal ), or when
a
and b
are not double-precision.
c = complex(a)
uses input a
as the real component of the complex output. The imaginary component is zero.
c = a + 0i
Example
Create complex uint8
vector from two real uint8
vectors.
a = uint8([1;2;3;4]) b = uint8([2;2;7;7]) c = complex(a,b) c = 1.0000 + 2.0000i 2.0000 + 2.0000i 3.0000 + 7.0000i 4.0000 + 7.0000i
See Also
![]() | compass | computer | ![]() |