How I can find in a big matrix the elements that are simultaneously min on rows and max on columns?
Mostrar comentarios más antiguos
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 comentarios
Azzi Abdelmalek
el 15 de Dic. de 2013
What if you have two minimum in the same row?
Image Analyst
el 15 de Dic. de 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
el 15 de Dic. de 2013
He said for example A=rand(50). It's just an example
Image Analyst
el 15 de Dic. de 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.
Respuesta aceptada
Más respuestas (1)
Matt J
el 15 de Dic. de 2013
rowmin=min(A,[],2);
colmax=max(A,[],1);
locations = bsxfun(@eq,A,rowmin) & bsxfun(@eq,A,colmax);
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!