function in the matlab
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi every one
I have written following function:
Mohamed
2 commentaires
Roger Stafford
le 1 Jan 2015
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
le 1 Jan 2015
@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?
Réponse acceptée
Roger Stafford
le 1 Jan 2015
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!