MATLAB: Averaging rows with rows previous averagedata 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? Best Answer Assuming the average includes the row in question:x = your matrixresult = cumsum(x)./(1:size(x,1))';Or for earlier versions of MATLAB:result = bsxfun(@rdivide,cumsum(x),(1:size(x,1))'); Related SolutionsMATLAB: How to sum elements in a matrix rowwise for specific columns only Where X is your matrix:Y = [X(:,1:6),sum(X(:,7:10),2)] MATLAB: Subtract row from previous row x(1:end-1)-x(2:end) Related QuestionSum specific range of column or rowHow to get sum of columns even if the matrix is a row vectorAverageFinding the sum across the columns in a matrixHow to fill NaN’s by averaging previous rowsHow to calculate slope of each row of a matrixRepeat previous row if condition
Best Answer