title: ValueError and odepack.error using integrate.odeint()
body: <p>I'm trying to write an equation to model and then plot an integral control system (specifically regarding cruise control). However I'm receiving two errors whenever I run it:</p>
  
  <p>ValueError: object too deep for desired array
  odepack.error: Result from function call is not a proper array of floats.</p>
  
  <p>I've read these questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/18184541/scipy-curve-fit-error-result-from-function-call-is-not-a-proper-array-of-floats">scipy curve_fit error: Result from function call is not a proper array of floats</a>   </li>
  <li><a href="https://stackoverflow.com/questions/20019427/how-to-solve-this-differential-equation-using-scipy-odeint">How to solve this differential equation using scipy odeint?</a></li>
  <li><a href="https://stackoverflow.com/questions/15709933/object-too-deep-for-desired-array-scipy-integrate-odeint">Object Too Deep for Desired Array - scipy.integrate.odeint</a></li>
  </ul>
  
  <p>Which seem like they should be helpful, however I'm unsure how to apply those to my problem.  I'm fairly new to python so please bear with me if I've missed something obvious or done something exceptionally silly.  I have no problems with plotting it, so once I figure out how to actually get this working I think I'm set.</p>
  
  <pre><code>import numpy as np
  import scipy.integrate as integrate
  
  ##Parameters
  
  kp=.5 #proportional gain
  ki=.1 #integral gain
  vr=30 #desired velocity in m/s
  Tm=190 #Max Torque in Nm
  wm=420 #engine speed
  B=0.4 #Beta
  an=12 #at gear 4
  p=1.3 #air density
  Cd=0.32 #Drag coefficient
  Cr=.01 #Coefficient of rolling friction
  A=2.4 #frontal area
  
  ##Variables
  
  m=18000 #weight
  v=20 #starting velocity
  time=np.linspace(0,10,50) #time
  theta=np.radians(4) #Theta
  
  def vderivs(state,t):
      v = state
      vel=[]
      ti=0
  
      while ti &lt; t:
          v1 = an*controller(ti,vr,v)*torque(v)
          v2 = m*Cr*np.sign(v)
          v3 = 0.5*p*Cd*A*v**2
          v4 = m*np.sin(theta)
  
          if t &lt; 10:
              vtot = v1+v2+v3
              vfin = np.divide(vtot,m)
          else:
              vtot = v1+v2+v3+v4
              vfin = np.divide(vtot,m)
  
          vel.append(vfin)
          ti+=1
  
      trueVel = np.array(vel, float)
      return trueVel
  
  def uderivs(state,t):
      v = state
      deltax = vr - v
      return deltax    
  
  def controller(time,desired,currentV):
      z = integrate.odeint(uderivs, currentV, time)
      u = kp*(vr-currentV)+ki*z
      return u.flatten()
  
  def torque(v):    
      return Tm*(1-B*(np.divide(an*v,wm)-1)**2)   
  
  def velocity(mass,desired,theta,t):
      v = integrate.odeint(vderivs, desired, t)
      return v.flatten()
  
  test = velocity(m,vr,theta,time)
  print(test)
  </code></pre>
  
  <p>Please let me know if there is anything else you need from me!</p>