I am trying to plot the picewise function below:
rho0 = 3*10e-11
Rd = 3.15
Rc = 7
def Density(rho0, r, Rc, Rd):
if r < Rc :
return rho0
elif r> Rc :
return rho0*np.exp(-(r-Rc)/Rd)
r = np.linspace(0,20, 1000)
y= Density(rho0, r, Rc, Rd)
plt.plot(r, y)
plt.show()
I am getting this error:
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
I do not know how can I solve this problem?or