title: take certain elements from an array
body: <p>is there an easy way to select let's say every 2 elements from an array taking the first nonzero element. My array is sparse double. For example:</p>
  
  <pre><code>val =
  
       (1,1)             0.1667
       (2,1)             0.1667
       (3,1)             0.1667
       (4,1)             0.1667
       (5,1)             0.1667
       (6,1)             0.1667
       (7,1)             0.1667
       (8,1)             0.1667
  </code></pre>
  
  <p>So I want to run my code taking 2 values in, next two values out and so on.
  Like this:</p>
  
  <pre><code>val = 
       (1,1)             0.1667
       (2,1)             0.1667
       (5,1)             0.1667
       (6,1)             0.1667
  </code></pre>
  
  <p>Below is my code, let's say I want to select every 2 elements starting from the first nonzero element. </p>
  
  <pre><code>results=zeros(86400,1); % time of the day in seconds
  for i=1:28,
      currentFlowArray=allFileMin(i).demand_pattern1.Wm.total.flowArray;
      for p=1:86400,
          results(p)=results(p)+ currentFlowArray(p);
      end
  end
  </code></pre>
  
  <p>Hope I was clear!
  Thank you in advance!</p>