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!