title: How to perform a TukeyHSD test in Matlab and get the grouped pairs using letters?
body: <p>How to perform a TukeyHSD post-hoc test after the Anova in Matlab, and get a table with the sorted grouped pairs using letters?</p>
  
  <p>Example:</p>
  
  <p>X has 3 treatments (columns) obtained in 4 replications (rows):</p>
  
  <pre><code>x=[9 1 3.1
     5 2 3.2
     7 1.1 3
     8 1.2 3]
  </code></pre>
  
  <p>The one-way ANOVA:</p>
  
  <pre><code>[p,a,s] = anova1(x)
  </code></pre>
  
  <p>And the multcompare result:</p>
  
  <pre><code>[c,m,h,nms] = multcompare(s)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/4yljq.png" alt="enter image description here"></p>
  
  <p>How to get a result like this?</p>
  
  <pre><code>treatment   mean      Tukey_group
  1           7.2500    a
  2           1.3250    b
  3           3.0750    b
  </code></pre>
  
  <p>Please see a similar example in R:</p>
  
  <p><a href="https://stats.stackexchange.com/questions/31547/how-to-obtain-the-results-of-a-tukey-hsd-post-hoc-test-in-a-table-showing-groupe">https://stats.stackexchange.com/questions/31547/how-to-obtain-the-results-of-a-tukey-hsd-post-hoc-test-in-a-table-showing-groupe</a></p>