title: Trapezoidal Numerical Integration in MATLAB without using a FOR loop?
body: <p>I'm following a Numerical Methods course and I made a small MATLAB script to compute integrals using the trapezoidal method. However my script uses a FOR loop and my friend told me I'm doing something wrong if I use a FOR loop in Matlab. Is there a way to convert this script to a Matlab-friendly one? </p>
  
  <pre><code>%Number of points to use
  N = 4;
  
  %Integration interval
  a = 0;
  b = 0.5;
  
  %Width of the integration segments
  h = (b-a) / N;
  
  
  F = exp(a);
  for i = 1:N-1
      F = F + 2*exp(a+i*h);
  end
  F = F + exp(b);
  F = h/2*F
  </code></pre>