MATLAB: Function in the matlab

unwrap

Hi every one
I have written following function:
Mohamed

Best Answer

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.