MATLAB: Check max value of an array against a constraint

search constraint

hi i have the following matrix
a= 1 1 1
5 0.6 1
2 0.5 0.9
how would i find the maximum value that is not > or = to 1 so in this case 0.9. Additionaly the matrix can be various dimensions.is it possible using the max command if not how would i approach this problem?

Best Answer

max(a(a<1));
and index of the location
a1 = a;
a1(a1<1) = -inf;
[value,i1] = max(a1(:));
[ii,jj] = ind2sub(size(a),i1);
out = [value, ii, jj];