[SciPy-User] Incoherent results with signal.impulse

0 views
Skip to first unread message

Cédrick FAURY

unread,
Nov 22, 2009, 7:50:47 AM11/22/09
to scipy...@scipy.org
Hello,

I have scipy 0.7.1, python 2.6, and when I do :

n = scipy.array([1])
d = scipy.array([0.01, 0.2, 1.0])
T, yout = scipy.signal.impulse((n,d))

it gives incoherent results for yout.

And that doesn't occurs with [1.0, 2.0, 1.0] denominator.

Is it a bug ?
I'm doing something wrong ?
Is anybody knows a solution ?
Thanks by advance

Cédrick FAURY

Warren Weckesser

unread,
Nov 22, 2009, 1:59:09 PM11/22/09
to SciPy Users List

Hi Cédrick,

scipy.signal.impulse assumes that the state matrix A is diagonalizable,
so it does not give a correct result when A is defective. I would call
that a bug. :)

The attached file contains the function impulse_response() that uses a
different method to compute the impulse response. If run as a script,
the code at the bottom of the file plots impulse responses computed by
impulse_response() and by scipy.signal.impulse() for your example, and
for two other values of the leading coefficient of your denominator.


Warren

> Thanks by advance
>
> Cédrick FAURY
>

> ------------------------------------------------------------------------
>
> _______________________________________________
> SciPy-User mailing list
> SciPy...@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>

impulse_response.py

Cédrick FAURY

unread,
Nov 22, 2009, 2:31:00 PM11/22/09
to scipy...@scipy.org
>
> >/ Hello,
> />/
> />/ I have scipy 0.7.1, python 2.6, and when I do :
> />/
> />/ n = scipy.array([1])
> />/ d = scipy.array([0.01, 0.2, 1.0])
> />/ T, yout = scipy.signal.impulse((n,d))
> />/
> />/ it gives incoherent results for yout.
> />/
> />/ And that doesn't occurs with [1.0, 2.0, 1.0] denominator.
> />/
> />/ Is it a bug ?
> />/ I'm doing something wrong ?
> />/ Is anybody knows a solution ?
> /

>
> scipy.signal.impulse assumes that the state matrix A is diagonalizable,
> so it does not give a correct result when A is defective. I would call
> that a bug. :)
>
> The attached file contains the function impulse_response() that uses a
> different method to compute the impulse response. If run as a script,
> the code at the bottom of the file plots impulse responses computed by
> impulse_response() and by scipy.signal.impulse() for your example, and
> for two other values of the leading coefficient of your denominator.
>
Thank you very much, it works fine now !
Actualy, if i'm right, the solution is to use lsim2 ?

Cédrick

Warren Weckesser

unread,
Nov 22, 2009, 2:38:29 PM11/22/09
to SciPy Users List

Yes, it uses lsim2, with the input U all zeros, and with the initial
condition set to the B matrix (plus the optional X0, if given).

Warren

Reply all
Reply to author
Forward
0 new messages