Programmer Guide/Command Reference/EVAL/complex arithmetic: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 8: Line 8:
;complex -> complex:
;complex -> complex:
:{|class="einrahmen"
:{|class="einrahmen"
!argument ''x''  
!argument ''xc''
| any complex type
|-
!result ''rc''
| same complex type as ''xc''
|}
 
:{|class="keinrahmen"
| '''<code>''rc''=cr2p(''xc'')</code>''' || ... convert ''xc'' from cartesian (real, imaginary) to polar (length, phase) format
|-
| '''<code>''rc''=cp2r(''xc'')</code>''' || ... convert ''xc'' from polar (length, phase) to cartesian (real, imaginary) format
|}
 
;complex -> real:
:{|class="einrahmen"
!argument ''xc''  
| any complex type
| any complex type
|-
|-
!result ''r''  
!result ''r''  
| same complex type as ''x''
| same ''real'' type as ''xc''  
|}
|}


:{|class="keinrahmen"
:{|class="keinrahmen"
| '''<code>''r''=cr2p(''xc'')</code>''' || ... convert from cartesian format (real, imaginary) to polar (length, phase)
| '''<code>''r''=cr2len(''xc'')</code>''' || ... compute length of ''xc''; ''xc'' is stored in cartesian format  
|-
| '''<code>''r''=cr2phi(''xc'')</code>''' || ... compute phase of ''xc''; ''xc'' is stored in cartesian format
|-
|-
| '''<code>''r''=cp2r(''xc'')</code>''' || convert from polar (length, phase) to cartesian format (real, imaginary)
| '''<code>''r''=cget(''xc'',0)</code>''' || ... get real part or length of ''xc'' (depends on format of ''xc'')
|-
| '''<code>''r''=cget(''xc'',1)</code>''' || ... get imaginary part or phase of ''xc'' (depends on format of ''xc'')
|}
|}





Revision as of 11:47, 7 April 2011

Because the current version of the STx EVAL command do not support a complex data type, a package of functions is used to implement arithmetic and special handling for complex numbers.

Note:

  • A numerical object containing N x M complex numbers (N>=1, M>=1), consists of 2N rows and M columns, because each complex number uses two cells of a row.
  • If a numerical object containing N x M complex numbers, is converted element-wise to real numbers, the resulting object consists of N rows and M columns.
complex -> complex
argument xc any complex type
result rc same complex type as xc
rc=cr2p(xc) ... convert xc from cartesian (real, imaginary) to polar (length, phase) format
rc=cp2r(xc) ... convert xc from polar (length, phase) to cartesian (real, imaginary) format
complex -> real
argument xc any complex type
result r same real type as xc
r=cr2len(xc) ... compute length of xc; xc is stored in cartesian format
r=cr2phi(xc) ... compute phase of xc; xc is stored in cartesian format
r=cget(xc,0) ... get real part or length of xc (depends on format of xc)
r=cget(xc,1) ... get imaginary part or phase of xc (depends on format of xc)


Usage
cp2r(xc) ... convert from polar to cartesian format
xc
a complex scalar, vector or matrix in polar format (length, phase)
Result
same type as xc, but the complex numbers are stored in the cartesian format (real part, imaginary part)
Usage
cr2len(xc) ... convert cartesian format to length (amplitude)
xc
a complex scalar, vector or matrix in polar format (length, phase)
Result
same type as xc, but the complex numbers are stored in the cartesian format (real part, imaginary part)


r with same length as x containing the converted window function


See also
window, fft

<function list>


cr2p

Convert Cartesian coordinates to Polar coordinates

Usage:

cr2p(xC)

Return Type:

like xC


complex numbers

Navigation menu

Personal tools