title: Matlab removing unwanted numbers from array
body: <p>I have got a matlab script from net which generates even numbers from an inital value. this is the code.</p>
  
  <pre><code>n = [1 2 3 4 5 6];
  iseven = [];
  for i = 1: length(n);
  if rem(n(i),2) == 0
  iseven(i) = i;
  else iseven(i) = 0;
  end
  end
  iseven
  </code></pre>
  
  <p>and its results is this</p>
  
  <pre><code>iseven =
  
       0     2     0     4     0     6
  </code></pre>
  
  <p>in the result i am getting both even numbers and zeros, is there any way i can remove the zeros and get a result like this</p>
  
  <pre><code>iseven =
  
           2    4     6
  </code></pre>