function in the matlab
2 次查看(过去 30 天)
显示 更早的评论
Hi every one
I have written following function:
Mohamed
2 个评论
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
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!