User Tools

Site Tools


implementation_unwrap_modulo

This is an old revision of the document!


C implementation of the Octave/Matlab unwrap function

The unwrap function in Octave/Matlab is simplifying the modulo of an arrray. It's an easy piece of code but handy to have it around off the shelf:

unwrap.c
int unwrap(int *values, int numberOfValues, int modulo)
{
    for (int i = 0; i < numberOfValues; i++)
    {
        while(values[i] > modulo/2 || values[i] < modulo/2)
        {
            (values[i] > modulo/2) ? values[i] -= modulo : values[i] += modulo;
        }
    }
}
implementation_unwrap_modulo.1537369872.txt.gz · Last modified: 2018/09/19 17:11 by supergnu