-1

I got these two functions:

mom=-1/2*q*x**2+1/2*q*len*x
quer=-q*x+1/2*q*len

where x is an array defined with numpy:

x=7
q=10
anzahl = 100
x=np.linspace(0, len, anzahl)

I am trying to get the MAX of 'mom' & 'quer" which I get with:

max(mom) & min(mom)

But now I'm trying to get the 'x' value where mom is MAX / MIN

I tried print (x.index(max(mom)) but I think this code doesn't connect the two functions in the right way.

0

1 Answer 1

2

In order to find the max index, try to use np.argmax(mom)! https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmax.html

In case of more max points, and all needed: How to make numpy.argmax return all occurrences of the maximum?

Sign up to request clarification or add additional context in comments.

6 Comments

perfect, that was the one I was looking for. What if there are 2 MIN / MAX values - in the docs there is only the case where 1 extreme is found: >>> np.argmax(b) # Only the first occurrence is returned.
If you need all the occurences, you can follow the strategy mentioned here: stackoverflow.com/questions/17568612/…
@LosKayos is this what you were looking for?
yes sir. thank you!
Can you mark it as solved then please? Thanks :)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.