| 2.1.22.2.1.41 fft_shift
 DescriptionThis function determines how the transformed data will be presented.
 Syntaxint fft_shift( vector<complex> & vSignal, vector & vFreq ) Parameters vSignal[modify] the original signal data for input, and the signal data after fft shift for output vFreq[modify] the original frequence sequence for input, and the frequence sequence  after fft shift for output
 ReturnReturns OE_NOERROR for success or error codes for failure.
 ExamplesPrior 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
  
#include <fft_utils.h> 
void fft_shift_ex1()
{
    vector<complex> vSignal = {36, -4 + 9.6569i, -4 + 4i, -4 + 1.6569i,
        -4,    -4 - 1.6569i, -4 - 4i, -4 - 9.6569i};
    vector vFreq = {0, 1, 2, 3, 4, 5, 6, 7};
    int nRet = fft_shift(vSignal, vFreq);    
    if( 0 != nRet )
    {
        printf("fft_shift function returned error: %d\n", nRet);
        return;
    }
}
//the result should be 
//vSignal = {    -4 - 1.6569i, -4 - 4i, -4 - 9.6569i,    36, -4 + 9.6569i, -4 + 4i, -4 + 1.6569i, -4}
//vFreq = {-3, -2, -1, 0, 1, 2, 3, 4}RemarkThis function determines how the transformed data will be presented.
 The effect on the FFT result is shifted around to be displayed with both positive and negative frequencies centered at zero, similar to displaying the phase in the range of -180 to +180.
 There is one extra frequency point involved in this presentation.
 Some symmetrical properties of FFT can be better seen in this form.
 See AlsoHeader to Includefft_utils.h
 Reference |