# [SciPy-user] Scilab to Scipy

Ryan May rmay31@gmail....
Fri Aug 22 11:39:05 CDT 2008

```On Fri, Aug 22, 2008 at 7:01 AM, peter websdell <

> 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?
>

Can you send/post an image somewhere that shows what you're expecting it to
look like?  I don't see any obvious problems with what you've written (other
than z=empty((100,100)) being extranenous).

Ryan

--
Ryan May