mardi 19 février 2019

If statment with an array of numbers

I have an array of numbers

x = np.arange(-5., 5., .001)

and an equation that is

y=somefunction(x*r) 

When x is less than the absolute value of.1, I want to let r=5, otherwise r=0. Then, I should get len(x) many values of y.

This is what I've tried:

if abs(x) < 2 : 
    r=5
else:
    r=0

Aucun commentaire:

Enregistrer un commentaire