complex
Returns a complex number composed of real elements.
Syntax
complex(x)
complex(r, im)
Inputs
- x
- A real number.
- r
- Real part of complex number.
- im
- Imaginary part of complex number.
Outputs
- R
- Complex number created from r and im.
Examples
Simple example for the usage of complex:
complex(1,8.2)
ans = [ 1 + 8.2i]
Single input example for complex. By calling iscomplex on ans, one can see that x was coverted to a complex from a real number:
complex(4)
ans = 4