2.1.22.2.1.45 fft_unwrap_phase


Description

Calculate the change in phi and add it to the previous phase.

Syntax

int fft_unwrap_phase( vector & vPhase )

Parameters

vPhase
[modify] the data for input, and the result of phase after transform 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_unwrap_phase_ex1()
{
    vector<complex> vSignal = {36, -4 + 9.6569i, -4 + 4i, -4 + 1.6569i,
        -4,    -4 - 1.6569i, -4 - 4i, -4 - 9.6569i};
    vector vPhase;
    vSignal.GetPhase(vPhase);
    
    //the result should be 
    //vPhase = {0, 1.9634, 2.3561, 2.7488, 3.1415, -2.7488, -2.3561, -1.9634}
    int nRet = fft_unwrap_phase(vPhase);
    if( 0 != nRet )
    {
        printf("fft_unwrap_phase function returned error: %d\n", nRet);
        return;
    }
}

Remark

In the unwrapping part that is to follow, we look at the difference

between the present and previous values returned by arctan2(), which

is in the range -PI to PI. Now if their difference is greater than 180,

we assume that it has crossed over the branch cut at +-PI. Then we

calculate the change in phi and add it to the previous phase.


WARNING - FOR THIS TO BE RIGHT, THE MAXIMUM PHASE FLUCTUATION SHOULD BE LESS THAN 180!!!

See Also

fftw_fft_unwrap_phase

Header to Include

fft_utils.h

Reference