Hi Powel,
1)You are correct that in recent MATLAB versions, the c-matrix output from multcompare includes a sixth column containing the p-value for each pairwise comparison. However, in MATLAB R2012b and earlier, the c-matrix only has five columns: group indices, group means difference, lower and upper confidence intervals, and the test statistic. The p-value column was added in later releases (around R2014b). Unfortunately, in your version, you cannot obtain p-values directly from the c-matrix output of multcompare. If you need p-values, you will need to compute them manually for each pairwise comparison, as shown in previous answers.
2)When you use multcompare(stats, 'CType', 'bonferroni'), MATLAB automatically applies the Bonferroni correction for you, adjusting the confidence intervals and significance tests accordingly. The Bonferroni method divides your chosen alpha-level by the number of pairwise comparisons. For example, if you have 4 groups (so 6 pairwise comparisons), the Bonferroni-corrected alpha for each test is 0.05/6 ≈ 0.0083. If you instead specify multcompare(stats, 'Alpha', 0.05/6), you are manually setting the per-comparison alpha to the Bonferroni-adjusted value. Both approaches are statistically equivalent in terms of significance thresholding, but using 'CType', 'bonferroni' is preferable because it also adjusts the confidence intervals appropriately, not just the alpha threshold.
3)Yes, you can limit the number of comparisons in post-hoc analysis. This is often desirable if you have specific hypotheses or only care about certain group differences. In MATLAB, you can specify which group pairs you want to compare using the 'ComparisonType' option (in newer versions) or by manually extracting and comparing only the desired pairs. For your version, you can subset the c-matrix after running multcompare to focus on the comparisons of interest, or you can manually perform t-tests (or other appropriate tests) only for the pairs you care about, applying the Bonferroni correction based on the number of those comparisons.
% Suppose you have run anova and have the stats structure
c = multcompare(stats, 'CType', 'bonferroni'); % c is N x 5 in R2012b
% To extract only comparisons where group 1 is compared to groups 2, 3, 4:
idx = (c(:,1) == 1) & ismember(c(:,2), [2 3 4]);
c_limited = c(idx, :);
disp(c_limited)
