@Tahariet Sharon It is true that multcompare cannot work with input from vartestn. A frustration with multcompare is that it cannot work as a standalone test; that is, it cannot receive as input a matrix of column data and perform a pairwise comparisons test on that data. That's unfortunate, in my view. However, multcompare can receive as input a stats object created from anova1. Below is a script that performs a pairwise comparisons test on a matrix of column data. The script loads some test data, creates a stats object from that data, then passes that object in to multcompare. Mission accomplished!
The 16x4 test data are in testdata.txt, which is attached. The file contains 16 marks on 4 tests. The last column of output produced by multcompare is the p-value for the hypothesis test that the corresponding mean difference is not equal to 0 for the pairs tested in that row. As seen below, the marks were significantly different (p < .05) between tests 1 and 3 and tests 2 and 3.
multcompare uses the Tukey-Kramer test by default, but other tests (e.g., Bonferroni) can be specified via the 'CType' option.
y = readmatrix('testdata.txt');
[~, ~, stats] = anova1(y, {'t1' 't2' 't3' 't4'}, 'off');
multcompare(stats, 'display', 'off')
ans =
1.0000 2.0000 -3.9088 -0.8750 2.1588 0.8711
1.0000 3.0000 -7.5338 -4.5000 -1.4662 0.0013
1.0000 4.0000 -4.8463 -1.8125 1.2213 0.3983
2.0000 3.0000 -6.6588 -3.6250 -0.5912 0.0130
2.0000 4.0000 -3.9713 -0.9375 2.0963 0.8464
3.0000 4.0000 -0.3463 2.6875 5.7213 0.1002