Contents Previous Next Subchapters

Element-By-Element Conversion To Complex
Syntax complex(value)
complex(
real partimaginary part)
See Also conj , imag

Description
Returns the element-by-element conversion of a single value or two values to a complex number.

complex(
value)
If value is complex, the return value is equal to value, otherwise the real part of the return value is equal to value.

complex(
real partimaginary part)
The return value has real part equal to real part and imaginary part equal to imaginary part, where real part and imaginary part are logical, character, integer, real or double-precision matrices.

Example

One Argument
     complex(1)
returns
     (1,0)
If value is a character matrix, complex will return the ascii value of each element of value. If you enter
     complex("mno")
O-Matrix will respond
     [ (109,0) , (110,0) , (111,0) ]
If value is a logical matrix, complex will return 1 for each true element and 0 for each false element. If you enter
     complex(true)
O-Matrix will respond
     (1,0)

Two Arguments
     complex(1, 2)
returns
     (1,2)
If you enter
     complex([1, 2, 3], [4, 5, 6])
O-Matrix will respond
     [ (1,4) , (2,5) , (3,6) ]
You can combine scalars with matrices of any dimension
     complex([1, 2, 3], 1.)
returns
     [ (1,1) , (2,1) , (3,1) ]