@Wayne, is your solution vulnerable to rounding error, with floating-point input? In general, might it not be safer to use something like the following--?
epsilon = 0.0001;
I = find(abs(x-maxval)<epsilon,1,'last');
@Azzi, very clever solution but is it not hard-coded for row vectors? In order to handle column vectors as well, shouldn't the 2nd line be something like the following--?