title: Matlab generate all possible team combinations
body: <p>There's lots of questions that are similar to mine but I haven't found quite what I'm looking for yet.
  I'm working on a project to optimize teaming in a class, and am not sure how to generate all possible team combinations.</p>
  
  <p>Say I have a vector that's a list of numbered people, like </p>
  
  <pre><code>&lt;1,2,3,4,5....,n&gt;
  </code></pre>
  
  <p>I want to generate all possible combinations of teams with <code>k</code> people per team, where <code>k</code> is smaller than <code>n</code>. 
  The output should be matrices where the rows are the teams. Each matrix will have <code>k</code> columns, and <code>n/k</code> rows (corresponding to the number of teams). </p>
  
  <p>For example, say my vector is<code>&lt;1,2,3,4&gt;</code>. I want all combinations of teams of 2. My possible output matrices would be <code>[1,2;3,4]</code>,<code>[1,3;2,4]</code>, and <code>[1,4;2,3]</code>. I'd like to know how to scale this up to any <code>n</code> and <code>k</code> value.</p>