Average every N rows by column
问题 I have four matrices that are 240x30. I need to calculate an average for every 15 rows and I need to do this by column. So, in the end I should have 30 columns with 16 values. So, for instance: myMatrix = randi(240,30) And this is what I have so far: averageBins = 15; meanByBinsMyMatrix = arrayfun(@(i) mean(myMatrix (i:i+averageBins-1)),1:averageBins:length(myMatrix )-averageBins+1)'; % the averaged vectormean() This seems to be working but I think it only does the job for the first column.