MATLAB: Finding out if the max value in a vector is in a certain interval in a vector

intervalvector

So im in need of a if statement that looks something like this:
%if max(C) == C(1,16)
% iMax = 1;
%elseif max(C) == C(17,32)
% iMax = 2;
%elseif max(C) == C(33,48)
% iMax = 3;
%elseif max(C) == C(49,64)
% iMax = 4;
%end
and I want to check if the max value in the (1,64)vector C lies in the interval of (1,16), (17,32), (33,48) or (49,64)
but this is probably not the way to do it.
need some help, thanks in advance!

Best Answer

[~,idx]=max(C); % location of max in C
imax=fix((idx-1)/16)+1; % compute the subsection