I have a 2000×2 matrix, and "for each 10×2 segment of this matrix", I need to calculate the maximum of corresponding values (second column) of repetitive values (first column) in the matrix. Like if the 3rd 10×2 segment of the matrix is this:
...[2 20;2 30;2 40;7 100;7 110;7 120;7 130;7 140;15 240;15 260] ...
I want to get this:
...[2 40;7 140;15 260] ...
And so on. I have written the following but it gives me the maximum of repetitive elements through the "whole matrix":
[uv,~,idx] = unique(A(:,1));B = [uv accumarray(idx,A(:,2),[],@max)];
But again, I need to do this "for each separate 10×2 segments of the matrix", and then store the results in a 'whatever x 2' sized matrix! Does anyone have any ideas how I could do this?
Best Answer