[SciPy-user] Scilab to Scipy
peter websdell
flyingdeckchair@googlemail....
Fri Aug 22 17:57:22 CDT 2008
Gotcha. Thanks for clarifying. I was being pretty dense. I've done a lot of
acoustic calculations in the past, but it's been a wee while. I'm convinced!
Pete.
2008/8/22 Warren Weckesser <warren.weckesser@gmail.com>
> Peter,
>
> 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);
> plot(x,sin(2*%pi*x));
>
> 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.
> Try this:
>
> x = linspace(0,100,101);
> plot(x,sin(2*%pi*x));
>
> 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.
>
>
> Good luck,
>
> Warren
>
>
>
> On Fri, Aug 22, 2008 at 4:01 PM, Warren Weckesser <
> warren.weckesser@gmail.com> wrote:
>
>> Hi Peter,
>>
>> On Fri, Aug 22, 2008 at 3:34 PM, peter websdell <
>> flyingdeckchair@googlemail.com> wrote:
>>
>>> Hello,
>>>
>>> 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.
>>
>>
>> Cheers,
>>
>> Warren
>>
>>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20080822/b98e8c56/attachment.html
More information about the SciPy-user
mailing list