I’m plotting a 3D surface in Python. Here muy1 and muy2 are two matrices created by meshgrid:
[[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]
[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]
[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]
...,
[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]
[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]
[-5. -4.75 -4.5 ..., 4.25 4.5 4.75]]
After that a function Z is calculated and plotted
Z=zeros((40,40))
for xi in x:
temp=1/2*(1-muy1)**2-1/2*(1-muy2)**2;
print temp;
Z=Z-temp;
print "Final"
print Z
However I keep getting Z to be 0. What is the reason for this?
tempis zero because it starts with1/2, which is integer division (resulting in zero). Use1./2or0.5in both places to prevent that.