title: Padding arrays with zeros dynamically - Octave / Matlab
body: <p>I have to add multiple arrays together in a for loop and the arrays will very in size so sometimes I will need to pad for the array x and sometimes I will need to pad for the array y how can I have the arrays padded dynamically?</p>
  
  <p><strong>I know how to pad manually (see code below) but how can I do it dynamically if the size of the array x or the size of the array y will vary?</strong>  </p>
  
  <pre><code>x = [1 2 3 4 5 6]'
  y = [3 5 7 8]';
  
  A = x + [y;zeros(2,1)];
  
  This will result in A = [4 7 10 12 5 6]'
  </code></pre>
  
  <p>PS: I'm using octave 3.8.1 with is like matlab</p>