Performs nFFT-point discrete Fourier transform or inverse Fourier transform.
int fft_real( int nFFT, vector & vSig, FFT_SIGN iSign = FFT_FORWARD )
- [input]number of points to do Fourier transform.
- [modify]For forward transform, it contains real signal to be transformed.
- For backward transform, it contains complex signal in Hermitian form.
- For forward transform, it contains the result of DFT in Hermitian form.
- For backward transform, it contains the result of IDFT.
- [input] the transformation to carry out
- = FFT_FORWARD: FFT (by default)
- = FFT_BACKWARD: IFFT.
Returns OE_NOERROR for success or error codes for failure.
Prior to compilation, load fft_utils.c to the workspace by executing the following LabTalk command:
To retain fft_utils.c in the workspace for successive sessions, drag and drop the file from the Temporary folder to the System folder.
//This example assumes a worksheet is active with four columns, where
//column 2 has the signal. Column 3 will be filled with the foward FFT result
//and column 4 will have the result of the IFFT. Column 4 should then have
//the same numbers as column 2.
Worksheet wks = Project.ActiveLayer();
Dataset dsData(wks, 1);
Dataset dsFFT(wks, 2);
Dataset dsIFFT(wks, 3);
// If all datasets are valid, then proceed
if( dsData && dsFFT && dsIFFT )
vec = dsData;
int nSize = vec.GetSize();
// Perform forward FFT with exact size of signal
int iRet = fft_real(nSize, vec);
if(0 != iRet )
printf("Forward FFT returned error: %d\n", iRet );
// Store forward FFT result
dsFFT = vec;
// Perform backward FFT from the forward FFT result
iRet = fft_real(nSize, vec, FFT_BACKWARD);
if(0 != iRet )
printf("Backward FFT returned error: %d\n", iRet );
// Store the backward FFT result
dsIFFT = vec;
Performs nFFT-point discrete Fourier transform (real->complex) or inverse Fourier transform (complex->real).
vSig will be padded with zeros if it has less than nFFT points and truncated if it has more.
Padding with zeroes, or zero-filling, results in an FFT spectrum with higher resolution. This works best
when the original signal ends in value at, or close to, zero.
For forward FT, the output is in Hermitian form;
For backward FT, the input sequence is in Hermitian form.
header to Include