Hi kcin,
I understand that you are trying to automate paired t-tests across all unique group combinations, and prepare the results for use with sigstar boxplot, without hardcoding each pair.
Here is one way to achieve the desired result:
- Combine all group data into a matrix Z (columns = groups)
- Used nested for loops to iterate over all unique group pairs
- Perform ttest() on each pair
- Collect p-values (ZP) and their corresponding group indices (ZH)
- Convert them into a structured format
ZPH = [num2cell(ZP(:)), ZH(:)];
to use with sigstar.
The relevant piece of code is given below:
ZP = [];
ZH = {};
index = 1;
for i = 1:4
for j = i+1:5
[~, p] = ttest(Z(:, i), Z(:, j));
ZP(index) = p;
ZH{index} = [i, j];
index = index + 1;
end
end
Hope this was helpful.