MATLAB: Scanning an entire table in blocks of 60s for max and min values

scanning table

a={rand(1877958,7); rand(1251972,7)};
b=cellfun(@(x) [x; repmat(x(end,:),-mod(size(x,1),-60),1)],a,'un',0)
for i=1:length(b)
mn(i)={max(reshape(b{i}(:,4),60,[])).'};
mx(i)={min(reshape(b{i}(:,5),60,[])).'};
end
Some good people on this forum gave me this code. This code allows the data to be grouped into rows of 60s and then find the max and min value. This code starts at row 1 to 60, 61 to 120, 121 to 180 and so on.
I want the cell array to be expanded and also look at: max and min value of rows 2 to 61, 62 to 121 and so on. max and min value of rows 3 to 62, 63 to 121 and so on. … max and min value of rows 58 to 117, 118 to 177 and so on. max and min value of rows 59 to 118, 119 to 178 and so on. max and min value of rows 60 to 119, 120 to 179 and so on. STOP
How can I add this expansion to this code? Any help is very much appreciated.

Best Answer

I would use the circshift function with it. Then put it in a loop to do what you want.
For example, this code shifts ‘A’ one row up, so that row #2 becomes row #1 after the shift, and so with the others. Note that the top row wraps to the bottom row with each shift, so you will have to take this into account when you write your code.
A = reshape([1:20],4,[])';
B = circshift(A, [-1 0]);