Unwrap lower than the default value (pi)

조회 수: 25 (최근 30일)
Pranjal Agrawal
Pranjal Agrawal 2023년 8월 7일
댓글: Bryan Wingert 2024년 7월 16일
Hi! Can anyone please elaborate on how to eliminate jumps that are less than pi?I have a function which varies from (0,pi/2). I want to unwrap the values in between that range. Can anyone please suggest on how to use this.
Thanks
  댓글 수: 2
Stephen23
Stephen23 2023년 8월 7일
multiply by four, UNWRAP, divide by four
Bryan Wingert
Bryan Wingert 2024년 7월 16일
This is a pretty clever hack of the unwrap function. It scales jumps from the threshold (pi/2 in this case) up to 2*pi, which guarantees that it gets unwrapped, since the unwrap function looks for jumps of 2*pi. (The threshold represents the bidirectional bound, e.g. [-pi,pi] for the default.) More specifically, the scaling factor is approximately 2*pi/threshold. Approximately because numerical error can throw it off sometimes.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sanjana
Sanjana 2023년 8월 21일
Hi Pranjal,
I understand that you are looking for a way to eliminate jumps that are less than pi. As per the official documentation of the,”unwrap” function, if a jump threshold less than pi is specified, then unwrap function uses the default jump threshold pi.
For eliminating jumps that are less than pi, a custom unwrapping algorithm can be implemented as follows,
% Let P be the phase vector
%Intialize unwrapped phase vector
unwrapped = zeros(size(P));
unwrapped (1) = P(1);
for i = 2:length(P)
diff = P(i)-P(i-1);%Calculating the jump
%check if jump is greater than threshold T
if diff > T
unwrapped(i) = P(i) - 2*pi;
elseif diff < -T
unwrapped(i) = P(i) + 2*pi;
else
unwrapped(i) = P(i);
end
end
Please refer to this following link, for further information,
Hope this helps!
Regards,
Sanjana
  댓글 수: 1
Bryan Wingert
Bryan Wingert 2024년 7월 16일
This only unwraps the point next to the jump, and leaves the rest of the vector untouched. The unwrap function cumulatively shifts the rest of the vector. Use Stephen23's hack above.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by