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
Voss
Voss 2022년 11월 23일
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Timing 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