Averaging rows with rows previous

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 日

0 投票

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))');

1 件のコメント

WBOZ11
WBOZ11 2018 年 2 月 22 日
Thank you so much!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2018 年 2 月 21 日

コメント済み:

2018 年 2 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by