title: generating step by step permutions with fixed order previous elements in Matlab
body: <p>I want to make a permutation of digits, step by step,
  first deciding whether <code>[1 2]</code> or <code>[2 1]</code>, then if <code>[2 1]</code> is accepted, deciding on the place of <code>3</code> i.e. </p>
  
  <pre><code>[3 2 1] or [2 3 1] or [2 1 3]. 
  </code></pre>
  
  <p>in other words, in each step the place of the former digits is fixed (<code>[2 1]</code> is fixed). 
  how can I generate such permutations in each step?</p>