Averaging rows with rows previous
2 次查看(过去 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?
0 个评论
采纳的回答
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!