%% Shift Phase Angle with Different Thresholds
% Shift the phase angle of a frequency response. The phase curve has two jumps. The first jump is 3.4250 radians between W = 3 and W = 3.4, and the second jump is 6.3420 radians between W = 5 and W = 5.4. Plot the phase curve.

clear; close all;
W = [0:0.4:3, 3.4:0.4:5, 5.4:0.4:7];
P = [-1.5723
     -1.5747
     -1.5790
     -1.5852
     -1.5922
     -1.6044
     -1.6269
     -1.6998
      1.7252
      1.5989
      1.5916
      1.5708
      1.5582
     -4.7838
     -4.8143
     -4.8456
     -4.8764
     -4.9002];
plot(W,P,'bo-')

% Use unwrap to shift the phase angle using the default jump threshold \pi radians. Plot the shifted phase curve. Both jumps are shifted since they are greater than the jump threshold \pi radians.

plot(W,unwrap(P),'ro-')

% Now shift the phase angle using a jump threshold of 5 radians. Plot the shifted phase curve. The first jump is not shifted since it is less than the jump threshold 5 radians.

plot(W,unwrap(P,5),'ro-')

%
% Copyright 2019 The MathWorks, Inc.