new column with running average of existing column

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 7 Mar 2022
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.
.

Più risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by