I have a vector and a cell array (with repeating strings) with the same size. The cell array defines the groups. I want to find min/max values in the vector for each group.
When faced with a similar problem*, I came up with this solution:
define the following function (in a .m file)
function i=argmax(x)
[~,i]=max(x);
end
then you can find the max locations as
gridx = accumarray(grnum,grnum,[],@(i)i(argmax(value(i))) );
and the max values as
grvalue = value(gridx);
(*if I understand your problem correctly)