# 2.1.22.2.1.41 fft_shift

## Description

This function determines how the transformed data will be presented.

## Syntax

int 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

## 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


#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}

## Remark

This 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.