new column with running average of existing column

1 次查看(过去 30 天)
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 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by