How to remove data noise through averaging adjacent elements in a data set.

3 ビュー (過去 30 日間)
Benjamin
Benjamin 2022 年 11 月 17 日
コメント済み: Voss 2022 年 11 月 23 日
I am trying to remove noise from my data that includes outliers which are skewing the final result. I'm wondering how I can average two adjacent elements sequentially for a whole data set in order to incorporate outliers more effectively and generate a more streamlined data set. For example, [a b c d e f g ...] it would look like (a+b)/2 and (c+d)/2 and (e+f)/2 ....and so on. I figured I should use a for loop but unsure what that would look like.

回答 (1 件)

Voss
Voss 2022 年 11 月 17 日
x = 1:10
x = 1×10
1 2 3 4 5 6 7 8 9 10
One way:
xm = movmean(x,2)
xm = 1×10
1.0000 1.5000 2.5000 3.5000 4.5000 5.5000 6.5000 7.5000 8.5000 9.5000
xm = xm(2:2:end)
xm = 1×5
1.5000 3.5000 5.5000 7.5000 9.5000
Another way:
xm = mean(reshape(x,2,[]),1)
xm = 1×5
1.5000 3.5000 5.5000 7.5000 9.5000
  2 件のコメント
Benjamin
Benjamin 2022 年 11 月 23 日
Got it. Thanks a million!
Voss
Voss 2022 年 11 月 23 日
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

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

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by