MATLAB: Finding max value in a matrix

max matrix column

I have a matrix with 5 columns and one million rows. How can I find the max value of every 60 rows in that rows of million

Best Answer

Reshape the array to a 3D array with 60 elements in the first dimension. Then find the maximum. The most work is required to consider that the 1st dimension is not a multiple of 60:
data = rand(1e6, 5);
siz = size(data);
s1 = siz(1) - mod(siz(1), 6);
x = reshape(data(1:s1, :), 60, s1/60, siz(2));
result = max(x, [], 1);