Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 !!

Respuesta aceptada

dpb
dpb el 30 de Sept. de 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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by