Borrar filtros
Borrar filtros

Performing a repeated calculation within a vector

1 visualización (últimos 30 días)
Dirk
Dirk el 7 de Dic. de 2015
Respondida: Walter Roberson el 7 de Dic. de 2015
Hi Everyone, I have a column of data, say with 40,000 data points. I want to reduce this to 4,000 by creating a new variable which is the mean of every 10 data points. So the new variable would have the mean of the first 10 data points, followed by the mean of the second 10 data points, and so on until there are 4,000 data points.Thanks.

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Dic. de 2015
Provided that the vector length is an exact multiple of the group size,
mean( reshape(TheVector, GroupSize, []) )
If there would be an incomplete group then you need to either pad the vector or else handle it differently. If you have a fairly new MATLAB then you can pad with NaN and use the 'omitnan' flag to mean(); see http://www.mathworks.com/help/matlab/ref/mean.html

Más respuestas (0)

Categorías

Más información sobre Logical 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