Effacer les filtres
Effacer les filtres

How to use loop function to find the 1st to Nth elements' average, and then 2nd to Nth element's average? Thanks

1 vue (au cours des 30 derniers jours)
Hi guys thanks for helping me. Suppose i have 700 data in a column, and i want to find out the first 120 elements' average. Then starting from this point, i want to find out the average of the sum of from 121st to the 700th, then from 122nd to 700th and so on. I know i have to use iteration to solve this, but i fail to set up a good algorithm and required syntax.
I am beginner of Matlab, please help me, thank you !!

Réponse acceptée

dpb
dpb le 30 Sep 2016
Navg=120; % number for moving average
krnl=ones(N,1)/N; % convolution kernel over N elements
xfilt=conv(x, krnl, 'valid') % filtered mean result over valid elements

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by