title: For loop over variable name in Octave
body: <p>I am applying transformations on a column by column basis to a matrix, the problem is that this transformation will not affect each column equally, leaving me with a collection of different length columns. I want to further iterate over these columns but cannot find the way to word it in Octave. </p>
  
  <pre><code>for v = 1:6
      gate_values( 1, (2*v)   ) = C(1, v);
      gate_values( 1, (2*v)-1 ) = t(1);
  
      for i = 1 : (length(C) - 1)
          if C( i+1, v ) - C(i, v) &gt; 0.05  % Taken as 10% of bin value
              gate_values( i+1, (2*v)   ) = C( i+1,v );
              gate_values( i+1, (2*v)-1 ) = t( i+1 );
          endif
      endfor
      t_imp = toc
  endfor 
  
  gate_values_1(:,1)= nonzeros( gate_values(:, 1) );
  gate_values_1(:,2)= nonzeros( gate_values(:, 2) );
  gate_values_2(:,1)= nonzeros( gate_values(:, 3) );
  gate_values_2(:,2)= nonzeros( gate_values(:, 4) );
  gate_values_3(:,1)= nonzeros( gate_values(:, 5) );
  gate_values_3(:,2)= nonzeros( gate_values(:, 6) );
  gate_values_4(:,1)= nonzeros( gate_values(:, 7) );
  gate_values_4(:,2)= nonzeros( gate_values(:, 8) );
  gate_values_5(:,1)= nonzeros( gate_values(:, 9) );
  gate_values_5(:,2)= nonzeros( gate_values(:,10) );
  gate_values_6(:,1)= nonzeros( gate_values(:,11) );
  gate_values_6(:,2)= nonzeros( gate_values(:,12) );
  </code></pre>
  
  <p>The nonzeros function means the columns will be different lengths so i cannot simply populate a matrix this way, would there be a way to create these gate_value columns by iterating for example I have tried (among variations).</p>
  
  <pre><code>for k=1:6
      gate_values_k(:,1) = nonzeros( gate_values(:,1) );
  </code></pre>
  
  <p>but this causes an error (for reference I'm assuming this is possible as in vba i could write gate_values_ &amp; k to achieve this). Thanks.</p>