unwrapMultipart

Unwrap vector of angles with NaN-delimited parts

Syntax

unwrapped = unwrapMultipart(p)
unwrapped = unwrapMultipart(p,angleUnit)

Description

unwrapped = unwrapMultipart(p) unwraps a row or column vector of azimuths, longitudes, or phase angles. Input and output units are both radians. If p is separated into multiple parts delimited by values of NaN, each part is unwrapped independently. If p has only one part, the result is equivalent to unwrap(p). The output is the same size as the input and has NaNs in the same locations.

unwrapped = unwrapMultipart(p,angleUnit) unwraps a row or column vector of azimuths, longitudes, or phase angles, where angleUnit specifies the unit used for the input and output angles: 'degrees' or 'radians'.

Examples

Example 1

Compare the behavior unwrapMultipart to that of unwrap. The output of unwrapMultipart starts over again at 6.11 following the NaN, unlike the output of unwrap. The output of unwrapMultipart is equivalent to a concatenation (with NaN-separator) of separate calls to unwrap:

p1 = [0.17          5.67          4.89          4.10]; 
p2 = [6.11          1.05          2.27]; 
unwrap([p1 NaN p2]) 

ans = 
    0.1700   -0.6132   -1.3932   -2.1832       NaN   -0.1732    1.0500    2.2700

unwrapMultipart([p1 NaN p2])

ans = 
    0.1700   -0.6132   -1.3932   -2.1832       NaN    6.1100    7.3332    8.5532

[unwrap(p1) NaN unwrap(p2)] 

ans = 
    0.1700   -0.6132   -1.3932   -2.1832       NaN    6.1100    7.3332    8.5532

Example 2

Wrap two revolutions of a sphere to π with wrapToPi, and then unwrap it with unWrapMultipart:

lon = wrapToPi(deg2rad(0:10:720));
unwrappedlon = unwrapMultipart(lon);
figure; hold on
plot(lon,'--')
plot(unwrappedlon)
xlabel 'Point Number'
ylabel 'Longitude in radians'

Introduced in R2007b