Is it possible to phase unwrap backwards??

36 views (last 30 days)
Lauren
Lauren on 2 Apr 2014
Answered: Roger Stafford on 2 Apr 2014
Hi,
So I've got a data set which I am carrying out a phase unwrap on. I am starting at the maximum point in my data, then I want to phase unwrap from that point to the right, and then from the same point to the left. I have coded it so that I have split the data in to two sets and I phase unwrap both individually then concatenate them. However, I want the first unwrap to go from the central position back to the first (below I have coded it from the first position to the central position), so essentially carry out the phase unwrap backwards through the data - is this possible?
Any help would be much appreciate!
phaseupper=Phase(2:pos0);
phaselower=Phase(pos0:end);
PhaseUnwrap1=phaseupper;
for i=2:length(phaseupper)
difference=phaseupper(i)-phaseupper(i-1);
if abs(difference) > 1.6*pi
PhaseUnwrap1(i:end)=PhaseUnwrap1(i:end)-2*pi;
end
end
PhaseUnwrap2=phaselower;
for i=2:length(phaselower)
difference=phaselower(i)-phaselower(i-1);
if abs(difference) > 1.6*pi
PhaseUnwrap2(i:end)=PhaseUnwrap2(i:end)-2*pi;
end
end
PhaseShift=PhaseUnwrap2-abs(PhaseUnwrap1(end));
PhaseUnwrap2=PhaseShift;
PhaseUnwrap=cat(1,PhaseUnwrap1,PhaseUnwrap2);

Answers (1)

Roger Stafford
Roger Stafford on 2 Apr 2014
The 'unwrap' function accepts the phase angle of the first element in its vector and corrects from there on to the end of the vector. I would suggest you first use it as it stands for your entire sequence from 1 to end. Then use the difference between the phases you obtain at 'pos0' to correct it by that much throughout the entire vector. That is, suppose, for example, you first obtain a phase angle of 7*pi+1.7 at pos0, whereas the original phase there was pi+1.7. In that case you would subtract 6*pi from every element, and then you would have the correct phase at pos0 and all other elements either going forward or backward would be corrected appropriately.
PhaseUnwrap = unwrap(Phase);
PhaseUnwrap = PhaseUnwrap - ...
2*pi*round((PhaseUnwrap(pos0)-Phase(pos0))/2/pi);
There is nothing magic about 'unwrap'. As I say, it accepts the first value unconditionally and after that merely corrects by a multiple of 2*pi each time it encounters a jump in absolute value in excess of pi radians. Using the above strategy is the equivalent of telling it to accept the value at pos0 and to then go both forward and backward from that point.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!