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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by