MATLAB: How to take the maximum value of an array

arraymax

Hi, I have this array a = [1:20]. How do I take the maximum value of every 5 elements of it. So I will have b = [5 10 15 20]. Anyone can help me? Thank you.

Best Answer

This works:
a = [1:20];
b = max(reshape(a, 5, []));