The t-test is a statistical test used to determine whether two sets of data are significantly different from each other. MATLAB has the built-in function ttest
to perform a t-test.
Here's an example code on how to perform a t-test in MATLAB with two sample sets:
main.m131 chars7 lines
The output values are:
h
- 1 if the null hypothesis is rejected (meaning the sets are significantly different), 0 if the null hypothesis is not rejectedp
- the p-value of the test (the probability of obtaining the observed difference by chance if the null hypothesis is true)ci
- the confidence interval for the true difference between the setsstats
- a structure containing various statistics such as the sample sizes, means, and standard deviations of the two sets.Note that the ttest2
function assumes that the two sets have equal variances. If the variances are unequal, you can use the ttest2('vartype','unequal')
syntax.
gistlibby LogSnag