MATLAB: Find the mean of every 5 values in an array

MATLAB

Hi, so I have an array of double
b=[ 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0]
How do I obtain the mean of every 5 values?

Best Answer

Lanceric - try using reshape to change your array from a 1x20 to a 5x4 array and then compute the mean from that. For example,
mean(reshape(b,[5,4]))