How can I calculate max and min in degree?

I've got an Array with my Phase Phi in degrees:[ 170°,179°,180°,-179°...] ranging from -180° to 180° and I want to calculate how much it drifts over time. My current method of
phi = [ 170,179,180,-179]
drift =max(phi)-min(phi)
doesn't work, because 180°-(-179°) = 359°, while it should be 11°(from 170° to -179°). The Problem is that degrees are a cylic(x°= (x-360)°) unit unlike most units.
Is the a smart way to calculate the maximum phase drift?

2 件のコメント

Image Analyst
Image Analyst 2014 年 4 月 11 日
If it goes from 179 to -179, isn't that a difference of 2? From 179 to 180 is 1, and 180 is the same as -180, so then from -180 to -179 is another 1, for a total of 2. At least that's how I view it.
Matthias
Matthias 2014 年 4 月 11 日
It was a little confusing. I tried to fix that. Now you can enter the Example in Matlab

サインインしてコメントする。

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 4 月 11 日
編集済み: Mischa Kim 2014 年 4 月 11 日

0 投票

How about
drift = max(abs(diff(phi)));
By the way, how do you get 11°? Is that from a different set of data points not shown in your vector above?

3 件のコメント

Matthias
Matthias 2014 年 4 月 11 日
編集済み: Matthias 2014 年 4 月 11 日
170° and -179° are 11° appart. I want the maximum overall drift. Diff would only give me neighbouring drifts.
If I had a non-cyclic unit like e.g. Volts this would simply be done by:
Vdrift = max(V) - min(V)
Mischa Kim
Mischa Kim 2014 年 4 月 11 日
編集済み: Mischa Kim 2014 年 4 月 11 日
Understood. Do you have access to the Statistics Toolbox?
phi = [170,179,180,-179]';
drift = max(pdist(phi + 360*(phi<0)));
Matthias
Matthias 2014 年 4 月 11 日
編集済み: Matthias 2014 年 4 月 11 日
This seems to just shift the problem:
phi = [4,-4]';drift = max(pdist(phi + 360*(phi<0)))
drift =
352

サインインしてコメントする。

Walter Roberson
Walter Roberson 2014 年 4 月 11 日

0 投票

Use unwrap() before the diff()

製品

タグ

質問済み:

2014 年 4 月 11 日

回答済み:

2014 年 4 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by