Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I print in index of my output for a numpy arange?

def x(t,A,ω,γ,ϕ):
return A*np.cos(np.sqrt(ω**2-(γ/2)**2)*t+ϕ)np.exp(-γt/2)

a=x(np.arange(0,10,0.01),1,1,1,-np.pi/2)

b=[np.max(np.abs(a)), ]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

print(b)

#This was the output [0.47310347814336845]

I want to know how can I get the index of the np.arange that this output belongs to?

>Solution :

You can use np.argmax():

np.argmax(np.abs(a))

This outputs:

121
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading