Programmer Guide/Command Reference/EVAL/fft: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 14: Line 14:
:;<var>n</var>: desired length of analysis window;
:;<var>n</var>: desired length of analysis window;
::*If <code>''n'' < nrow(''x'')</code>, the analysis window length L is set to nrow(''x''), otherwise L is set to ''n''.
::*If <code>''n'' < nrow(''x'')</code>, the analysis window length L is set to nrow(''x''), otherwise L is set to ''n''.
::*If the analysis window length L is a power of 2 (L=2^M), the '''fft''' algorithm is used, otherwise the '''dft''' is used.
::*If the analysis window length L is a power of 2 (L=2<sup>M</sup>), the '''fft''' algorithm is used, otherwise the '''dft''' is used.
::*If L is greater than [[../nrow|nrow(''x'')]], zero padding is applied to the signal.
::*If L is greater than [[../nrow|nrow(''x'')]], zero padding is applied to the signal.
:;<var>ytype</var>: select the type and format of the computed spectrum (see '''Result 3''')
:;<var>ytype</var>: select the type and format of the computed spectrum (default=0) &rarr; see '''Result 3'''
:;<var>poffset</var>: offset in samples to the signal begin or the selected ''zero phase'' position (default=0)
:;<var>poffset</var>: offset in samples to the signal begin or the selected ''zero phase'' position (default=0)
:::{|class="keinrahmen"
:::{|class="keinrahmen"
|''poffset''='''0'' ||-> <code>phase[i] = atan2(im[i], re[i])</code>
|''poffset''='''0''' ||&rarr; <code>phase[i] = atan2(im[i], re[i])</code>
|-
|-
|otherwise ||-> <code>phase[i] = (atan2(im[i], re[i]) - 2*pi*i/L * ''poffset'') % (2 * pi)</code>
|otherwise ||&rarr; <code>phase[i] = (atan2(im[i], re[i]) - 2*pi*i/L * ''poffset'') % (2 * pi)</code>
|}
|}
:;<var>prange</var>: selects the range of phase values
:;<var>prange</var>: selects the range of phase values (default=0)
:::{|class="keinrahmen"
:::{|class="keinrahmen"
|''prange''='''0'' ||-> <code>0 <= phase[i] < 2*pi</code>
|''prange''='''0''' ||&rarr; <code>0 &le; phase[i] < 2*pi</code>
|-
|-
|otherwise ||-> <code>-pi <= phase[i] < pi</code>
|otherwise ||&rarr; <code>-pi &le; phase[i] < pi</code>
|}
|}
;<var>aref</var>: reference amplitude if the log. spectrum (''ytype''=4) is requested (default=1)
:;<var>aref</var>: reference amplitude if the log. spectrum (''ytype''=4) is requested (default=1)
;Result: A matrix ''y'' with [[../ncol|ncol(''x'')]] columns, where each column ''y''[*,j] contains the spectrum of the column (channel) ''x''[*,j]. The type and the length of the spectra is selected by the argument ''ytype''.
;Result 3: A matrix ''y'' with [[../ncol|ncol(''x'')]] columns, where each column ''y''[*,j] contains the spectrum of the column (channel) ''x''[*,j]. The type and the length of the spectra is selected by the argument ''ytype''.
::{|class="einrahmen"
::{|class="einrahmen"
!''ytype'' !! description !! content of y[*,j] !! nrow(y)
!''ytype'' !! description !! content of ''y''[*,j] !! nrow(''y'')
|-
|-
|'''0'''  
|'''0'''  
Line 41: Line 41:
|'''1'''
|'''1'''
|complex spectrum in polar format
|complex spectrum in polar format
|<code>{ amp<sub>0</sub>, phase<sub>0</sub>, amp<sub>1</sub>, phase<sub>1</sub>, ... }<BR>with: amp<sub>i</sub>=sqrt(re<sub>i</sub><sup>2</sup> + im<sub>i</sub><sup>2</sup>)<BR>     phi<sub>i</sub> see ''poffset''</code>
|<code>{ amp<sub>0</sub>, phase<sub>0</sub>, amp<sub>1</sub>, phase<sub>1</sub>, ... }<BR>with: amp<sub>i</sub>=sqrt(re<sub>i</sub><sup>2</sup> + im<sub>i</sub><sup>2</sup>),<BR>phase<sub>i</sub> see ''poffset''</code>
|L+2
|L+2
|-
|-
Line 59: Line 59:
| L+1
| L+1
|}
|}
----
;See also: [[../ifft|ifft]], [[../dft|dft]], [[../dct|dct]], [[../cepstrum|cepstrum]], [[../lpc|lpc]], [[../complex arithmetic|complex arithmetic]]


;See also: [[Programmer_Guide/Command_Reference/EVAL/ifft|ifft]], [[Programmer_Guide/Command_Reference/EVAL/dft|dft]], [[Programmer_Guide/Command_Reference/EVAL/dct|dct]], [[Programmer_Guide/Command_Reference/EVAL/cepstrum|cepstrum]], [[Programmer_Guide/Command_Reference/EVAL/lpc|lpc]], , [[Programmer_Guide/Command_Reference/EVAL/complex arithmetic|complex arithmetic]]
[[../#Functions|<function list>]]
 
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Latest revision as of 20:22, 21 April 2011

Compute the discrete fourier transform of a real signal using the fft or the dft algorithm.


Usage 1
fft(n)
n
desired signal window length (scalar)
Result 1
The next (nearest) possible signal window length.

Usage 2
fft(x)
x
signal vector or matrix; if x is a matrix a spectrum of each column is computed
Result 2
A matrix y with ncol(x) columns and L+2 rows, where each column y[*,j] contains the complex spectrum of the column (channel) x[*,j]. The transformation length L is set to npow2(nrow(x)).

Usage 3
fft(x, n {, ytype, poffset, prange, aref})
x
signal vector or matrix; if x is a matrix a spectrum of each column is computed
n
desired length of analysis window;
  • If n < nrow(x), the analysis window length L is set to nrow(x), otherwise L is set to n.
  • If the analysis window length L is a power of 2 (L=2M), the fft algorithm is used, otherwise the dft is used.
  • If L is greater than nrow(x), zero padding is applied to the signal.
ytype
select the type and format of the computed spectrum (default=0) → see Result 3
poffset
offset in samples to the signal begin or the selected zero phase position (default=0)
poffset=0 phase[i] = atan2(im[i], re[i])
otherwise phase[i] = (atan2(im[i], re[i]) - 2*pi*i/L * poffset) % (2 * pi)
prange
selects the range of phase values (default=0)
prange=0 0 ≤ phase[i] < 2*pi
otherwise -pi ≤ phase[i] < pi
aref
reference amplitude if the log. spectrum (ytype=4) is requested (default=1)
Result 3
A matrix y with ncol(x) columns, where each column y[*,j] contains the spectrum of the column (channel) x[*,j]. The type and the length of the spectra is selected by the argument ytype.
ytype description content of y[*,j] nrow(y)
0 complex spectrum in cartesian format { re0, im0, re1, im1, ... } L+2
1 complex spectrum in polar format { amp0, phase0, amp1, phase1, ... }
with: ampi=sqrt(rei2 + imi2),
phasei see poffset
L+2
2 amplitude spectrum { amp0, amp1, ... } L+1
3 power spectrum { amp02, amp12, ... } L+1
4 logarithmic amplitude spectrum { lev0, lev1, ... }
with: levi=20*log10(ampi/aref)
L+1

See also
ifft, dft, dct, cepstrum, lpc, complex arithmetic

<function list>

Navigation menu

Personal tools