In python to find the index of the minimum value of the array I usey = numpy.argmin(someMat)
Can i find the minimum value of this matrix such that it does not lie within a specified range in a neat way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“Can i find the minimum value of this matrix such that it does not lie within a specified range in a neat way?”
If you only care about the minimum value satisfying some condition and not the location, then
If you do want the location via argmin, then that’s a bit trickier, but one way is to use masked arrays:
Note that the condition here is flipped, as the mask is True for the excluded values, not the included ones.
Update: it appears that by “within a specified range” you don’t mean the minimum value isn’t within some bounds, but that you want to exclude portions of the matrix from the search based on the x,y coordinates. Here’s one way (same matrix as before):
with the corresponding masked array variant if you need the locations. [Edited to use indices instead of mgrid; I’d actually forgotten about it until it was used in another answer today!]
If I’m still wrong :^) and this also isn’t what you’re after, please edit your question to include a 3×3 example of your desired input and output.