How I can find in a big matrix the elements that are simultaneously min on rows and max on columns?
Afficher commentaires plus anciens
For example I have
A=rand(50,50);
And I want to find the position and the values that are simultaneously min on rows and max on columns
4 commentaires
Azzi Abdelmalek
le 15 Déc 2013
What if you have two minimum in the same row?
Image Analyst
le 15 Déc 2013
How can that happen, unless he would have integers? Each row will have exactly one element that is the min. Same for the columns. Of course being the min element on a row does not mean that same element is also the min element of the column it is in - in fact, it probably won't be.
Azzi Abdelmalek
le 15 Déc 2013
He said for example A=rand(50). It's just an example
Image Analyst
le 15 Déc 2013
Exactly. So there will never be two minimums in the same row. And, for a given row, whatever column the row min does occur in will only be the max of the column it's in 1 time in 50. So most of the time he won't find any elements meeting the criteria. Perhaps you and I are interpreting what he said differently.
Réponse acceptée
Plus de réponses (1)
Matt J
le 15 Déc 2013
rowmin=min(A,[],2);
colmax=max(A,[],1);
locations = bsxfun(@eq,A,rowmin) & bsxfun(@eq,A,colmax);
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!