title: How to initialize a vector in MATLAB as per a pattern?
body: <p>I am completely new to MATLAB.This may be a rather basic question.</p>
  
  <p>Given numerical values for <code>size</code>, <code>extras</code> and <code>max</code>, I need to initialize a 1 X N vector such that the first <code>size</code> elements are 1, the next <code>size</code> are 2, the next <code>size</code> are 3 and so on till the last <code>size</code> elements are set to <code>max</code>. So I need to initialize <code>size</code> number of elements successively to <code>x</code> such that <code>x</code> increments from 1 to <code>max</code>. The extras are the number of leftover cells which are initialized to 0. To illustrate:</p>
  
  <pre><code>size = 3; %# (is same as the quotient of N/max)
  extras = 1; %# (is same as remainder of N/max) 
  max = 3; 
  N = 10;
  
  original_vector = [0 0 0 0 0 0 0 0 0 0];
  </code></pre>
  
  <p>The desired output is </p>
  
  <pre><code>Required_vector = [1 1 1 2 2 2 3 3 3 0]
  </code></pre>