Unexpectred results using Mod and Unwrap

조회 수: 7 (최근 30일)
Ruben de Bruin
Ruben de Bruin 2012년 10월 23일
I was playing with the Unwrap function when I noticed some unexpected results when working with a phase angle in degrees instead of radians.
The unwarp function unwarps a signal by adding or subtracting a multiple of 2*x. So, in theory unwarp(signal,x) and mod(signal, 2*x) should cancel eachother. This is true for x=pi, but does not seem to hold for any other number. See the example below:
x = pi; % x=pi : ok, x=4 : trouble
% Make some random numbers
signal = 2*x*rand(1,1000);
% Mod(signal,2*x) should be equal to Mod(unwrap(signal,x),2*x)
plot(mod(signal,2*x), mod(unwrap(signal,x),2*x));
Can anybody tell me what I'm missing?

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 23일
This caught me off guard a few years ago. The answer is that although you can adjust the jump tolerance, you cannot adjust the amount of the jump.
See http://www.mathworks.com/help/matlab/ref/unwrap.html and think about the implications of the note highlighted there about the effect of specifying a tolerance less than Pi (i.e., that the lower tolerance doesn't change the jump value in that note.)

추가 답변 (1개)

Ruben de Bruin
Ruben de Bruin 2012년 10월 23일
thanks Walter! You just saved my evening :-)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by