Check max value of an array against a 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?

 Accepted 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];

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Asked:

AI
on 17 Apr 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!