[SciPy-User] Roots of a signal

josef.pktd at gmail.com josef.pktd at gmail.com
Mon Feb 8 16:10:48 EST 2010


On Mon, Feb 8, 2010 at 3:14 PM, Nils Wagner
<nwagner at iam.uni-stuttgart.de> wrote:
> Hi all,
>
> How can I compute the roots of a signal ?
>
> The following didn't work due to a memory error.
>
> from scipy.interpolate import splrep, splev, sproot
> from numpy import exp, sin, linspace, pi
> from pylab import plot, show, legend
> t = linspace(0,4,20)
> y = exp(-0.1*t)*sin(2*pi*t)
> plot(t,y,label='Signal')
> tck = splrep(t,y)
> t_new = linspace(0,10,40)
> y2 = splev(t_new,tck)
> plot(t_new,y2,label='Spline')
> roots = sproot(tck,10)
> legend(loc=0)
> show()
>
>
> Any pointer would be appreciated.

your script finishes without problem for me

>>> roots
array([  1.32135351e-18,   5.01642799e-01,   9.99383967e-01,
         1.50051340e+00,   2.00014353e+00,   2.49953905e+00,
         3.00076843e+00,   3.49870336e+00])

from the plot (of only the first half) and

>>> np.diff(y2>0).sum()
9

it looks like there is one root missing

Josef


>
> Thanks in advance
>
>                                  Nils
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list