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

7 Ansichten (letzte 30 Tage)
Benjamin
Benjamin am 17 Nov. 2022
Kommentiert: Voss am 23 Nov. 2022
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.

Antworten (1)

Voss
Voss am 17 Nov. 2022
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 Kommentare
Voss
Voss am 23 Nov. 2022
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by