There a many functions you can use for this (accumarray, splitapply, etc.) but with any of them you're going to have to build a vector of row index to your grouping function.
[group, value] = findgroup(round(Sorted_ENP(:,end),1));
rows = (1:size(Sorted_ENP, 1))';
max_idx = splitapply(@custom_max, Sorted_ENP(:,end-1), rows, group)
array2table([value, max_idx], 'VariableName', {'x', 'max', 'max_idx'})
With
function max_idx = custom_max(vector, rowindices)
[maxval, loc] = max(vector);
max_idx = [maxval, rowindices(loc)];
end
Best Answer