Borrar filtros
Borrar filtros

Averaging rows with rows previous

3 visualizaciones (últimos 30 días)
WBOZ11
WBOZ11 el 21 de Feb. de 2018
Comentada: WBOZ11 el 22 de Feb. de 2018
I have data in a matrix where I need each consecutive row to be the average of all the rows above this. How would I go about this?

Respuesta aceptada

James Tursa
James Tursa el 21 de Feb. de 2018
Editada: James Tursa el 21 de Feb. de 2018
Assuming the average includes the row in question:
x = your matrix
result = cumsum(x)./(1:size(x,1))';
Or for earlier versions of MATLAB:
result = bsxfun(@rdivide,cumsum(x),(1:size(x,1))');

Más respuestas (0)

Categorías

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