fft_real

 

Description

Performs nFFT-point discrete Fourier transform or inverse Fourier transform.

Syntax

int fft_real( int nFFT, vector & vSig, FFT_SIGN iSign = FFT_FORWARD )

Parameters

nFFT
[input]number of points to do Fourier transform.
vSig
[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.
iSign
[input] the transformation to carry out
= FFT_FORWARD: FFT (by default)
= FFT_BACKWARD: IFFT.

Return

Returns OE_NOERROR for success or error codes for failure.

Examples

Prior to compilation, load fft_utils.c to the workspace by executing the following LabTalk command:

Run.LoadOC("Originlab\fft_utils.c", 16);

To retain fft_utils.c in the workspace for successive sessions, drag and drop the file from the Temporary folder to the System folder.

EX1

//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.
 
#include <fft_utils.h> 
void fft_real_ex1()
{
    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 )
    {
        vector vec;
        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 );
            return;
        }
        // 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 );
            return;
        }
        // Store the backward FFT result
        dsIFFT = vec;
    }
}

Remark

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.

See Also

fft_complex

header to Include

fft_utils.h

Reference