title: Time dependent input in scipy.integrate.odeint?
body: <p>I want to integrate a square wave as input to a coupled differential equations using odeint. The code below seems to working, however, it throws an error:
  "IndexError: index out of bounds" on line number 12.</p>
  
  <p>Can anyone help me with this ? </p>
  
  <p>Thanks in advance,</p>
  
  <p>Jyotika</p>
  
  <pre><code>   1 import pylab as pl
     2 import numpy as np
     3 from scipy.integrate import odeint
     4 
     5 
     6 def func1(Rates,time,ip):
     7         # 0 = x, 1 = y
     8         # dx/dt = -x+ ax+by, dy/dt =-y+ cx+dy
     9         leak = -0.3
     10         a = d = 0.1     
     11         b = c = -0.2    
     12         dxbydt = leak*Rates[0]+ a*Rates[0]+b/2.*Rates[1]+ip[time]
     13         dybydt = leak*Rates[1]+ c*Rates[0]+d*Rates[1]+ip[time]
     14                                 
     15         return [dxbydt, dybydt]
  
     16 time = np.arange(0,1000,1)
     17 ip = np.zeros((len(time)))
     18         
     19 ip[300:600] = 5.0
     20 initR = np.ones((2))*10
     21 fR = odeint(func1,initR,time,args=(ip,))
     22         
     23 pl.figure()
     24 #pl.plot(time,ip,'k-',label='ip')
     25 pl.plot(time,fR[:,0],'b-',label='x')
     26 pl.plot(time,fR[:,1],'r-',label='y')
     27 pl.legend()
     28 
     29 pl.show()
  </code></pre>