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?
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 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!