[SciPy-User] Wrong Step Response

otti otti at gargamels-haus.net
Wed May 23 04:01:31 EDT 2012


Hello everyone,

after reading some threads about step response problems in the mailing list
i couldnt come up with a proper solution for my problem.

I've got the following transfer function:

G = Vr/(sT1*(1+sT2))

Vr = 2/15
T1 = 0.2
T2 = 1

For this i like to plot the step response so i made the following script:

*---Begin Script*

# some imports
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
from scipy import signal

# Constants
T1 = 0.2
T2 = 1
Vr = float(2)/15
Tsim = 50

# Denumerator
N0 = np.array([T1*T2 ,T1 , 0])

# numerator
Z0 = Vr

# create tfcn
sys = sp.signal.lti(Z0, N0)

# create the step response
t = np.linspace(0, Tsim, 1000)
u = np.arange(len(t))
u = np.ones_like(u)
yout = sp.signal.lsim2(sys, T=t, U=u)[1]

plt.figure(1)
plt.plot(t, u, t, yout/yout.max())
plt.grid("on")
plt.xlabel("t")
plt.ylabel("h(t)")
plt.title("Sprungantwort")
plt.show()

*---End Script*

This gives me the following response, which i know is not the rigth one 
because i made this one
already in a lab at university with MATLAB but i don't have MATLAB at 
home because i prefer to use Numpy+Scipy+Matplotlib.

wrong step response

Here is the correct response:

correct step response

After several hours of reading an trying different approaches im kind of 
frustrated ^^.

I would be really thankfull for any help so that i can keep on going the 
Scipy track.


Greetings,
William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120523/83ed8763/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: step_response.png
Type: image/png
Size: 38727 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120523/83ed8763/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TA1.jpg
Type: image/jpeg
Size: 66953 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20120523/83ed8763/attachment.jpg>


More information about the SciPy-User mailing list