Averaging rows with rows previous

3 次查看(过去 30 天)
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?

采纳的回答

James Tursa
James Tursa 2018-2-21
编辑:James Tursa 2018-2-21
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))');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by