title: Making a for-loop in Matlab faster by using arrayfun?
body: <p>currently I have the following portion of code:</p>
  
  <pre><code>for i = 2:N-1
    res(i) = k(i)/m(i)*x(i-1) -(c(i)+c(i+1))/m(i)*x(N+i) +e(i+1)/m(i)*x(i+1);
  end
  </code></pre>
  
  <p>where as the variables k, m, c and e are vectors of size N and x is a vector of size 2*N. Is there any way to do this a lot faster using something like arrayfun!? I couldn't figure this out :( I especially want to make it faster by running on the GPU later and thus, arrayfun would be also helpfull since matlab doesn't support parallelizing for-loops and I don't want to buy the jacket package...
  Thanks a lot!</p>