# [SciPy-user] Scilab to Scipy

Fri Aug 22 14:34:29 CDT 2008

```Hello,

Thanks for the advice warren. However, the scilab code actually produces the
results I am expecting. I will post a picture next week.

What I don't understand is that python takes the exact same input,
processess the data in the same way and then produces different results.

Like I say, I'll post piccies next week. Adios for noo.

Thanks again,
Pete.

>
>
> On Fri, Aug 22, 2008 at 12:37 PM, Warren Weckesser <
> warren.weckesser@gmail.com> wrote:
>
>> Peter,
>>
>> The problem is in your original scilab code.  You say
>>     x = linspace(0,100);
>> and in the calculation of the mode, you have the term sin(Kx*x). Since Kx
>> = 2*pi, and your x ranges from 0 to 100, you should see 100 oscillations in
>> the x direction.  You don't see it, because your grid is too coarse.  The
>> default number of samples for the linspace function is 100.
>>
>> What you really want is 0 <= x <= Lx.  In your scilab code, x should be
>> set like this:
>>     x = linspace(0,Lx,grid_size)
>> The third argument, as its name suggests, is the number of samples to use.
>>
>> Here's a modified version of your scilab code (I also changed e^(%i*w*t)
>> to cos(w*t), but that was not the source of the problem):
>>
>> ####################
>> 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;
>>
>> grid_size = 501;
>> x = linspace(0,Lx,grid_size);
>> y = linspace(0,Ly,grid_size);
>> z = zeros(grid_size,grid_size);
>>
>> for i = 1:grid_size
>>     for j = 1:grid_size
>>         z(i,j) = A * sin(Kx*x(i)) * sin(Ky*y(j)) * cos(w*t);
>>     end
>> end
>>
>> contour(x,y,z,20)
>>
>> ####################
>>
>> Cheers,
>>
>> Warren
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080822/8f76290f/attachment.html
```