TomCmplx

From TomWiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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:
   a
 
Imaginary part:
   b
 
>> z2 = z.*z
 
z2 = tomCmplx(1x1):
Real part:
   a*a-b*b
 
Imaginary part:
   a*b+b*a

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.)