MATLAB: How to find maximum before a certain element in the matrix

maximum of certain elements in matrix

For example B=[5 8 5 2 6 9 10] min(B)=2
I am looking for maximum point before min(B), which is 8 (not maximum of B elements, which is 10)

Best Answer

B=[5 8 5 2 6 9 10] ;
[~,ind] = min(B);
maxB4min = max(B(1:ind))
=8