MATLAB Answers

running mean of circular data (angles)

69 ビュー (過去 30 日間)
Jakob Sievers
Jakob Sievers 2011 年 10 月 5 日
コメント済み: Walter Roberson 2020 年 5 月 7 日
Hi there
Im trying to do a running mean of a quite large wind-direction data-set but I'm having trouble finding solutions that work. Does anyone know of a simple solution?
Thanks in advance

  1 件のコメント

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 5 日
>> doc mean

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

採用された回答

Mark Brandon
Mark Brandon 2011 年 10 月 5 日
You could look at the excellent "Circular Statistics Toolbox"

  5 件のコメント

表示 2 件の古いコメント
Ana Soph
Ana Soph 2020 年 5 月 6 日
Thanks good man
Ana Soph
Ana Soph 2020 年 5 月 6 日
  1. how can i use mean angle?
  2. M = xlsread('Dic2019','Dic2019mat')
  3. ten_minute_avarege = meanangle(reshape(M, 10, []), 'omitnan')
  4. xlswrite('datosexcel1.xlsx', ten_minute_avarege, 'Hoja1', 'A1');
Walter Roberson
Walter Roberson 2020 年 5 月 7 日
I am not aware of any meanangle() function that has 'omitnan' as an option.

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

その他の回答 (2 件)

David Young
David Young 2011 年 10 月 5 日
Have a look at
doc unwrap

  0 件のコメント

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


Jakob Sievers
Jakob Sievers 2011 年 10 月 5 日
The Circular Statistics Toolbox doesnt appear to have a running mean function though. I have used its circ_mean function to make my own running mean but it takes hours to complete its calculation due to the size of the dataset (basically a long vector containing 10 million points).
Does anyone have any other suggestions?

  4 件のコメント

表示 1 件の古いコメント
Jakob Sievers
Jakob Sievers 2011 年 10 月 5 日
Well. I looked though the running mean function that I usually use, but it uses a trick looking like this: cumsum(angles)./wl where wl is the window length being meaned over, and im not sure how to transfer this fast method into a circular-data setting. So what I did was to do a "for" loop which continuously uses the circ_mean function from the above mentioned toolbox. Since I have this long dataset it takes around 5 hours to calculate it and im sure it can be done more easily. Im just not sure how.
What I did with your suggestion was:
angles2=unwrap(angles);
angles2_rm=runmean(angles2,100); %(where 100 is the window)
and then im thinking using the mod function to get back into circular mode:
mod(angles2_rm,360)
but it doesnt look right.
David Young
David Young 2011 年 10 月 5 日
Note that unwrap assumes your angles are in radians. If you're using degrees (and from the 360 in your code I think you are), multiply your data by pi/180 before using unwrap. You can convert back afterwards if necessary by multiplying by 180/pi.
Also, perhaps there's a problem with runmean. Maybe you could explain a little more about what this function does, or if it's very short even copy it into your question. (Not into a comment or answer though.)
Jakob Sievers
Jakob Sievers 2011 年 10 月 5 日
Hi David
I just talked with a colleague who said that a 30min mean would be sufficient, meaning that I can make a simple running mean that runs in a 20 seconds or so myself using the circ_mean as described above. Thanks for the help though!

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

Community Treasure Hunt

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

Start Hunting!

Translated by