how i average n values in array

5 visualizaciones (últimos 30 días)
yasmeen hadadd
yasmeen hadadd el 21 de Ag. de 2016
Comentada: Walter Roberson el 21 de Ag. de 2016
if i have data a and i want to mean or average every 10 values as 1:10, 2:11, 3:12 and as so on for length of data ?

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Ag. de 2016
mean(reshape(YourData, 10, []))
  8 comentarios
Andrei Bobrov
Andrei Bobrov el 21 de Ag. de 2016
Hi Walter! Small correcting.
cs = cumsum(YourData(:));
moving_average = (cs(10:end) - [0;cs(1:end-10)])/10;
Walter Roberson
Walter Roberson el 21 de Ag. de 2016
Thanks, Andrei

Iniciar sesión para comentar.

Más respuestas (2)

Star Strider
Star Strider el 21 de Ag. de 2016
‘But i need overlap between the values as 1:10 then from 2:11 and so on’
Use a moving average filter:
Heart_pulse_avg = filter(ones(1,10), 10, Heart_pulse);
  1 comentario
Steven Lord
Steven Lord el 21 de Ag. de 2016
Use the movmean function if you're using release R2016a or later.

Iniciar sesión para comentar.


Andrei Bobrov
Andrei Bobrov el 21 de Ag. de 2016
a - your vector;
out = movsum(a,[0 9],'Endpoints','discard')/10;

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by