title: IndexError: index x is out of bounds for axis 0 with size x
body: <p>I am going to plot the velocity function of time, when I have gathered acceleration function of time.
  However, I get an error code, <code>IndexError: index 51 is out of bounds for axis 0 with size 51</code>, 51 is the last index of my data, as my data is set up like this: <code>f.write(str(akselerasjon) + &quot;   &quot;+ str(tid) + &quot;\n&quot;)</code>, gathered it in MicroPython. However, the error takes place in python where I am dealing with the data.</p>
  <p>This is my code:</p>
  <pre><code># -*- coding: utf-8 -*-
  &quot;&quot;&quot;
  Created on Sat May 22 21:04:05 2021
  
  @author: Petter Jansen Ytterdahl
  &quot;&quot;&quot;
  
  from matplotlib import pyplot as plt
  import numpy as np
  
  def rektangelmetoden(aks, tid):
      a_v = len(tid)
      vm = [0]
      t_v = 0
      
      for i in range(a_v - 1):
          h = tid[i + 1] - tid[i]
          t_v += aks[i] * h
          vm.append(t_v)
      return(vm)    
  
  f = np.loadtxt(&quot;målinger.txt&quot;, float, skiprows = 0)
  acceleration = f[:, 0]
  time = f[:, 1]
  
  gravitational_acceleration = 9.81 
  mass = 0.5
  k = 0.01 
  
  m_v = []
  m_t = []
  t_start = 0
  t_end = 5
  steps = 1000
  length_steps = (t_end-t_start)/(steps-1) 
   
  velocity = np.zeros(steps) 
  time = np.zeros(steps) 
  
  for i in range(steps-1):
      velocity[i+1] = velocity[i] + length_steps * (gravitational_acceleration - k * velocity[i]**2 / mass)
      time[i+1] = time[i] + length_steps 
  
  velocity_r = rektangelmetoden(acceleration, time)
  
  plt.plot(time, velocity, color = &quot;b&quot;, label = &quot;Teoretisk modell&quot;)
  plt.plot(time, velocity_r, color = &quot;r&quot;, label = &quot;målinger&quot;)
  plt.xlabel(&quot;Time [s]&quot;)
  plt.ylabel(&quot;Velocity [m/s]&quot;)
  plt.title(&quot;Micro:Bit in parachute&quot;)
  plt.grid()
  plt.legend()
  </code></pre>
  <p>The error takes place in this line (line 18):</p>
  <pre><code>t_v += aks[i] * h
  </code></pre>
  <p>I did see a few other similar errors on Stackoverflow, but I am too stupid to understand most of them, so please help, Thanks.</p>