% unwrapping the phase for i = 1:length(PhaseRange)-1 cols = PhaseRange(i+1,:)-PhaseRange(i,:) > pi; if (sum(cols)>0) colsIdx = find(cols ~=0); for jj = 1:length(colsIdx) PhaseRange(i+1,colsIdx(jj)) = PhaseRange(i+1,colsIdx(jj))-2*pi; end end cols1 = PhaseRange(i+1,:)-PhaseRange(i,:) < -pi; if (sum(cols1)>0) colsIdx = find(cols1 ~=0); for jj = 1:length(colsIdx) PhaseRange(i+1,colsIdx(jj)) = PhaseRange(i+1,colsIdx(jj))+2*pi; end end if cols1==cols & sum(cols1) > 0 display('At the same time PhaseRange(i+1)-PhaseRange(i)<> \pi') end end