title: Rolling sum in Matlab
body: <p>I have an cross-sectional array with columns as prices for each date. I want to create another array with a rolling sum for window of 30 days. I would prefer not to use a for loop.
  Currently, I am using the following code for one column:</p>
  
  <pre><code>for i=31:n
   for j=i-30:i-1
    x = x + y(j)
   end
  sum(i) = x
  end
  </code></pre>
  
  <p>I need to this for all securities and thus the code will have to run multiple times for all elements in a dataset.</p>