Correct phase angles to produce smoother phase plots
Q = unwrap(P)
Q = unwrap(P,tol)
Q = unwrap(P,,dim)
Q = unwrap(P,tol,dim)
Q = unwrap(P) corrects
the radian phase angles in a vector
P by adding
multiples of ±2π when absolute jumps
between consecutive elements of
P are greater than
or equal to the default jump tolerance of π radians. If
unwrap operates columnwise. If
a multidimensional array,
unwrap operates on
the first nonsingleton dimension.
Q = unwrap(P,tol) uses
a jump tolerance
tol instead of the default value, π.
Q = unwrap(P,,dim) unwraps
dim using the default tolerance.
Q = unwrap(P,tol,dim) uses
a jump tolerance of
A jump tolerance less than π has the same effect as a
tolerance of π. For a tolerance less than π, if a jump
is greater than the tolerance but less than π,
adding ±2π would result in a jump larger
than the existing one, so
unwrap chooses the
current point. If you want to eliminate jumps that are less than π,
try using a finer grid in the domain.
The following phase data comes from the frequency response of
a third-order transfer function. The phase curve jumps
w = 3.0 and
w = 3.5, from
w = [0:.2:3,3.5:1:10]; p = [ 0 -1.5728 -1.5747 -1.5772 -1.5790 -1.5816 -1.5852 -1.5877 -1.5922 -1.5976 -1.6044 -1.6129 -1.6269 -1.6512 -1.6998 -1.8621 1.7252 1.6124 1.5930 1.5916 1.5708 1.5708 1.5708 ]; semilogx(w,p,'b*-'), hold
unwrap to correct the phase angle,
the resulting jump is
2.6959, which is less than
the default jump tolerance π. This figure
plots the new curve over the original curve.
P features smoothly increasing phase
angles except for discontinuities at elements
P = [ 0 7.0686 1.5708 2.3562 0.1963 0.9817 1.7671 2.5525 6.6759 1.1781 1.9635 2.7489 0.5890 1.3744 2.1598 2.9452 ]
Q = unwrap(P) eliminates these
Q = 0 7.0686 1.5708 2.3562 0.1963 7.2649 1.7671 2.5525 0.3927 7.4613 1.9635 2.7489 0.5890 7.6576 2.1598 2.9452
Usage notes and limitations:
Row vector input is only supported when the first two inputs are vectors and nonscalar.
Performs arithmetic in the output class. Therefore, results might not match MATLAB® due to different rounding errors.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).