title: Performing an averaging operation over every n elements in a vector
body: <p>I have a logical vector in which I would like to iterate over every n-elements. If in any given window at least 50% are 1's, then I change every element to 1, else I keep as is and move to the next window. For example.</p>
  
  <pre><code>n = 4;
  
  input = [0 0 0 1 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 1];
  
  output = func(input,4);
  
  output = [0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 1];
  </code></pre>
  
  <p>This function is trivial to implement but is it possible to apply a vectorized implementation using logical indexing?. I am trying to build up the intuition of applying this technique.</p>