[Numpy-discussion] empty data matrix (are they really empty ?)
Giorgio Luciano
giorgio.luciano at chimica.unige.it
Thu Dec 14 07:31:47 CST 2006
I was converting a matlab file to my new favority scientific language
Numpy :)
In the old file I created a matrix on the fly. I know that Numpy and
python cannot do that so I found a workaround
here's the code
lev2=empty((1,h))
ir=1
for j in arange(1,nstep+2):
#a=gr[[arange(ir-1,ir+nstep)],:]
a2=gr[arange(ir-1,ir+nstep)]
#flev=dot(a2,dot(disper,a2.transpose()))
clev=diag(dot(a2,dot(disper,a2.transpose())))
lev2=vstack((lev2,clev))
#print ir
#print clev
#print h
ir=ir+nstep+1
lev=lev2[1:,]
print lev
So
First I create the empty matrix
Secon perform the calculation
Third take the matrix and exclude the first line since it has "dummy"
values because after I need to plot it with
contour(lev)
H,K = meshgrid(lab,lab)
fig=p.figure()
ax=p3.Axes3D(fig)
ax.plot_wireframe(H,K,lev)
p.show()
p.close
everything works fine.. but is this really necessary ? could not an empy
just just be "really empty" ?
Thanks for the answers
Cheers
Giorgio
More information about the Numpy-discussion
mailing list