setting an array element with sequence problem problem
Debashish Saha
silideba at gmail.com
Fri Apr 27 14:18:15 EDT 2012
from __future__ import division
from numpy import*
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import jv
from scipy.special import yn
h_cross=1
m=1
E=np.linspace(0.1,10,100)
V0=-100
R=2
K=(2*E)**0.5
K_P=(2*(E-V0))**0.5
'''r=np.linspace(-10,10,1000)
def V(r):
if r>0 and r<R:
return V0
return 0
V=np.vectorize(V)
ax.set_ylim(-200,10)
plt.plot(r,V(r))'''
def sph_jv(l,r):
return (pi/(2*r))**0.5*jv(l+0.5,r)
def sph_yn(l,r):
return (pi/(2*r))**0.5*yn(l+0.5,r)
def delta_l(K,l):
return arctan(((K_P*R)**2*sph_jv(l,K*R)-(2*l+3)*(K*R)*sph_jv(l+1,K*R))/((K_P*R)**2*sph_yn(l,K*R)-(2*l+3)*(K*R)*sph_yn(l+1,K*R)))
l=6
delta_l=np.vectorize(delta_l)
plt.plot(K,delta_l(l,K))
plt.show()
ValueError Traceback (most recent call last)
C:\Python27\lib\site-packages\IPython\utils\py3compat.pyc in
execfile(fname, glob, loc)
166 else:
167 filename = fname
--> 168 exec compile(scripttext, filename, 'exec') in glob, loc
169 else:
170 def execfile(fname, *where):
C:\Users\Neeraj\Desktop\14.py in <module>()
45 l=6
46 delta_l=np.vectorize(delta_l)
---> 47 plt.plot(K,delta_l(l,K))
48
49 display(gcf())
C:\Python27\lib\site-packages\numpy\lib\function_base.pyc in
__call__(self, *args)
1880 if self.nout == 1:
1881 _res = array(self.ufunc(*newargs),copy=False,
-> 1882 subok=True,dtype=self.otypes[0])
1883 else:
1884 _res = tuple([array(x,copy=False,subok=True,dtype=c) \
ValueError: setting an array element with a sequence.
More information about the Python-list
mailing list