function in the matlab

조회 수: 6 (최근 30일)
Paul
Paul 2015년 1월 1일
편집: Paul 2015년 1월 5일
Hi every one
I have written following function:
Mohamed
  댓글 수: 2
Roger Stafford
Roger Stafford 2015년 1월 1일
I should think it would be easy to write such a function. For the initial value of W you would use the Q(1) value as is, which means that W would necessarily initially fall between -pi and +pi. After that, if the absolute value of the difference between a Q value and the previous W value is greater than pi, then add or subtract whatever integral multiple of 2*pi to or from Q is required to make that absolute value be less than pi. The altered Q would then be the next W. This allows subsequent values of W to fall outside the -pi to +pi range in a manner depending on the sequence of Q values.
Out of curiosity, why would you wish to avoid matlab's 'unwrap' function, however? Is there some aspect of Mathworks' function that you wish to change, or is it that you simply like to experiment on your own?
Roger Stafford
Roger Stafford 2015년 1월 1일
@Mohammadreza. Can you describe the particular way (aspect) in which your proposed 'unwrapp' would differ from Mathworks' 'unwrap'? Just consider that Q is an series of abstract numbers that all lie between -pi and +pi and forget about 'pipes' and 'noise'. Exactly what rules would you use to compute W from this sequence of Q values?

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

채택된 답변

Roger Stafford
Roger Stafford 2015년 1월 1일
If Q is a vector, I would suggest the following:
W = zeros(size(Q));
W(1) = Q(1);
for k = 2:length(Q)
W(k) = Q(k) + 2*pi*round((W(k-1)-Q(k))/(2*pi));
end
This ensures that successive values, W(k-1) and W(k), can differ in absolute value by no more than pi, and that W(k) will always be equal to Q(k) plus or minus an integral multiple of 2*pi.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by