Sign in

username:

password:



Not a member?

Search Online Books



Search tips

Free Online Books

Sponsor

NEW! TMS320C6474: 3x the performance. 1/3 the cost. Three 1 GHz cores on 1 chip.

Chapters

Chapter Contents:

Search Mathematics of the DFT

  

Book Index | Global Index


Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?

  

Complex Numbers in Matlab and Octave

Matlab and Octave have the following primitives for complex numbers:

octave:1> help j

j is a built-in constant
 
 - Built-in Variable: I
 - Built-in Variable: J
 - Built-in Variable: i
 - Built-in Variable: j

A pure imaginary number, defined as `sqrt (-1)'.  The `I' and `J'
forms are true constants, and cannot be modified.  The `i' and `j'
forms are like ordinary variables, and may be used for other
purposes.  However, unlike other variables, they once again assume
their special predefined values if they are cleared *Note Status
of Variables::.

Additional help for built-in functions, operators, and variables
is available in the on-line version of the manual.  Use the command
`help -i <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help-octave@bevo.che.wisc.edu
mailing list.

octave:2> sqrt(-1)
ans = 0 + 1i

octave:3> help real
real is a built-in mapper function

 - Mapping Function:  real (Z)
     Return the real part of Z.

See also: imag and conj. ...

octave:4> help imag
imag is a built-in mapper function

 - Mapping Function:  imag (Z)
     Return the imaginary part of Z as a real number.

See also: real and conj. ...

octave:5> help conj
conj is a built-in mapper function

 - Mapping Function:  conj (Z)
     Return the complex conjugate of Z, defined as 
     `conj (Z)' = X - IY.

See also: real and imag. ...

octave:6> help abs
abs is a built-in mapper function

 - Mapping Function:  abs (Z)
     Compute the magnitude of Z, defined as 
     |Z| = `sqrt (x^2 + y^2)'.

     For example,

          abs (3 + 4i)
          => 5
...
octave:7> help angle
angle is a built-in mapper function

 - Mapping Function:  angle (Z)
     See arg.
...
Note how helpful the ``See also'' information is in Octave (and similarly in Matlab).



Subsections

Order a Hardcopy of Mathematics of the DFT

Previous: Matlab/Octave Examples
Next: Complex Number Manipulation

written by Julius Orion Smith III
Julius Smith's background is in electrical engineering (BS Rice 1975, PhD Stanford 1983). He is presently Professor of Music and Associate Professor (by courtesy) of Electrical Engineering at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), teaching courses and pursuing research related to signal processing applied to music and audio systems. See http://ccrma.stanford.edu/~jos/ for details.


Comments


No comments yet for this page


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )