필터 지우기
필터 지우기

Averaging rows with rows previous

조회 수: 3 (최근 30일)
WBOZ11
WBOZ11 2018년 2월 21일
댓글: WBOZ11 2018년 2월 22일
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