# mean of matrix elements

4 visualizaciones (últimos 30 días)
john creighton el 15 de Oct. de 2014
Comentada: john creighton el 16 de Oct. de 2014
hey all. i have a 5760x1 matrix. i need to find the average of the first 10 elements, remove the 10 elements and replave with the averaged number, find the average of the next 10 elements, remove those 10 elements and replace with average and so on.... could anyone give me an insight as to how to do this? much appreciated john
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

Sean de Wolski el 15 de Oct. de 2014
B = mean(reshape(x,10,[]))'
Where x is your original column vector and B is the mean of every 10x1 chunk
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Más respuestas (3)

Andrew Reibold el 15 de Oct. de 2014
Editada: Andrew Reibold el 15 de Oct. de 2014
myMatrix = rand(5760,1)
for jj = 1:576
moving_avg(jj,1) = mean(myMatrix(jj*10-9:jj*10));
end
Will make a matrix called 'moving_avg' where each point represents the average of each set of 10 points.
Is that what you wanted? It will be 1/10 the size.
##### 1 comentarioMostrar NingunoOcultar Ninguno
Andrew Reibold el 15 de Oct. de 2014
Its very easy to replace every single point with the average too if thats what you need. (Same size, but every set of 10 numbers are all the same averaged number.)

Iniciar sesión para comentar.

Andrei Bobrov el 16 de Oct. de 2014
I want have 'vote' too!
out = accumarray(ceil((1:numel(x))'/10),x(:),[],@mean);
##### 2 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
john creighton el 16 de Oct. de 2014
haha. yours works too...so well deserved 'vote' :)

Iniciar sesión para comentar.

john creighton el 16 de Oct. de 2014
Both answers worked perfectly. Thanks guys. sorry can only accept one answer lol
##### 1 comentarioMostrar NingunoOcultar Ninguno
Sean de Wolski el 16 de Oct. de 2014
You can vote too :)

Iniciar sesión para comentar.

### Categorías

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