MATLAB: How to calculate cumulative average of every n values in a matrix

average of 3 consecutive rows

Hi, I have 300×20 matrix (A). How to calculate average of every 3 consecutive rows of each column to have output matrix B (100×20)?

Best Answer

B = (A(1:3:end,:)+A(2:3:end,:)+A(3:3:end,:))/3
Related Question