how to perform a two samples t test and a paired t test in matlab

For a two samples t-test in Matlab, you can use the ttest2 function. Here's an example of how you can perform a two-sample t-test:

main.m
data1 = [5 4 3 6 7];
data2 = [8 7 6 9 10];

[h, p, ci, stats] = ttest2(data1, data2);
86 chars
5 lines

For a paired t-test, you can use the ttest function in Matlab. Here's an example:

main.m
before = [5 4 3 6 7];
after = [8 6 4 9 10];

[h, p, ci, stats] = ttest(after, before); % Note the order of input here (after, before)
134 chars
5 lines

related categories

gistlibby LogSnag