[SciPy-user] Scilab to Scipy
Fri Aug 22 15:21:02 CDT 2008
In case you are not convinced, here is a simpler demonstration of the
problem with your scilab code. The graph of sin(2*pi*x) for 0 <= x <= 100
should be 100 oscillations. Try this in scilab:
x = linspace(0,100);
You will see a *single* oscillation! The problem is that the spacing between
the x coordinates is 100/99 = 1.0101..., which is just slightly larger than
the actual period of the oscillations. So each sample catches one of the
oscillations at increasing phase values within the oscillation, and creates
the illusion of a single oscillation, when in fact, there should be 100
oscillations. If the number of samples is increased to 101, then the
spacing of the samples is exactly 1, and the plot will be identically 0.
x = linspace(0,100,101);
and you'll see a horizontal line.
The basic problem is that Lx is the length of the plate, but you are not
scaling your x coordinates to be in the range 0 <= x <= Lx when you compute
the mode. The code that I sent in my first email shows one way to fix this.
On Fri, Aug 22, 2008 at 4:01 PM, Warren Weckesser <
> Hi Peter,
> On Fri, Aug 22, 2008 at 3:34 PM, peter websdell <
> firstname.lastname@example.org> wrote:
>> Thanks for the advice warren. However, the scilab code actually produces
>> the results I am expecting.
> Only by a remarkable stroke of luck does it create a "correct" picture
> when n=2 and m=2. Try changing to n=1 and rerun the scilab code. Or try
> changing your grid size from the default of 100 to something even a little
> larger, say 101 (i.e. add a third argument of 101 to the linspace commands,
> adjust the initialization of z to "z=zeros(101,101)", and change the for
> loop limits appropriately). Your scilab plot will be a mess, like the one
> I'm looking at right now.
>> 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.
> Basically, the scilab code is bad, and you are recreating the bug in the
> python code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user