From TomWiki
Jump to navigationJump to search

The solvers in the TOMLAB suite work with real numbers. Still, some equations are more easily expressed using complex numbers.

The tomCmplx class makes it possible to represent symbolic complex expressions as pairs of ordinary tomSym expressions. For example:

>> toms a b
>> z = tomCmplx(a,b)
z = tomCmplx(1x1):
Real part:
Imaginary part:
>> z2 = z.*z
z2 = tomCmplx(1x1):
Real part:
Imaginary part:

The set of operations allowed for tomCmplx expressions is currently very limited. Element-wise addition, subtraction, multiplication, division and exponentiation are supported, as are real(), imag(), abs() and angle() which return real-valued tomSym expressions.

If a tomCmplx is used in an equation, then a cell array of two equations is generated; One for the real and one for the imaginary component. A complex number can never be used in an inequality, so <= and >= are not supported for tomCmplx. (But inequalities can be used on the real and imaginary parts, as those are normal tomSym expressions.)