title: nth permutation of a vector in MATLAB
body: <p>Suppose I have a vector of integers like this:</p>
  
  <pre><code>A = [1 2 3]
  </code></pre>
  
  <p>What I need is nth permutation of vector <code>A</code>. As we now a vector of <code>n</code> numbers has <code>n!</code> permutation, For example some permutation of <code>A</code> is:</p>
  
  <pre><code>[1 2 3]
  [1 3 2]
  [2 1 3]
  [2 3 1]
  ...
  </code></pre>
  
  <p>Is there any built-in function for calculating nth permutation? if not, can anyone please offer me a efficient algorithm for calculate it? Any suggestion would be highly appreciated </p>