new column with running average of existing column

조회 수: 1 (최근 30일)
Samantha Huff
Samantha Huff 2022년 3월 7일
답변: Star Strider 2022년 3월 7일
I am trying to create a new column that has the average of the 10 data points before and after that time point from an existing column (peak heights). Obviously there will be some difficulty for the first 10 and last 10 rows.

채택된 답변

Star Strider
Star Strider 2022년 3월 7일
Try this —
T1 = table(randn(20,1))
T1 = 20×1 table
Var1 _________ 0.24004 0.36596 0.63986 -2.6273 -0.5487 -1.7412 -0.40701 0.31528 -0.62188 0.95605 -0.17599 0.83996 0.3583 -0.050693 -0.85835 0.032795
T1.Var2 = movmean(T1.Var1,[10 10])
T1 = 20×2 table
Var1 Var2 _________ _________ 0.24004 -0.32772 0.36596 -0.23041 0.63986 -0.18513 -2.6273 -0.17553 -0.5487 -0.22105 -1.7412 -0.20518 -0.40701 -0.22255 0.31528 -0.18343 -0.62188 -0.13606 0.95605 -0.15936 -0.17599 -0.15936 0.83996 -0.18038 0.3583 -0.21073 -0.050693 -0.26077 -0.85835 -0.11286 0.032795 -0.083805
See the documentation on movmean for details.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by