[SciPy-user] Scilab to Scipy
peter websdell
flyingdeckchair@googlemail....
Fri Aug 22 09:01:34 CDT 2008
Hello all,
I'm converting from using sclab/matlab to python. I'm finding it great so
far, but I've discovered a problem that I don't understand.
The following code displays a contour plot of the natural modes of a plate
in scilab:
###################
Lx=1;
Ly=1;
n=2;
m=2;
f=100;
w=2*%pi*f;
t=1;
A=2;
Kx=n*%pi/Lx;
Ky=m*%pi/Ly;
x=linspace(0,100);
y=linspace(0,100);
z=zeros(100,100);
for i = 1:100
for j = 1:100
z(i,j) = A * sin(Kx*x(i)) * sin(Ky*y(j)) * %e^(%i*w*t);
end
end
contour(x,y,z,20)
##################
Now here's how I've done it in python:
##################
from pylab import *
Lx=1
Ly=1
n=2
m=2
f=100
w=2*pi*f
t=1
A=2
Kx=n*pi/Lx
Ky=m*pi/Ly
x,y =mgrid[0:100,0:100]
z=empty((100,100))
z=A * sin(Kx*x) * sin(Ky*y) * e**(1j*w*t)
contour(x,y,z)
show()
###################
The result does plot a contour, but it is garbage. I have tried replecating
the silly for loop approach, and also using the real of abs value of the
result, but it is still garbage.
Can anyone offer some advice as to why the two scripts produce different
results?
Thanks a lot,
Pete.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080822/bf2bf938/attachment.html
More information about the SciPy-user
mailing list