To perform a t-test in matlab, you can use the ttest function from the Statistics and Machine Learning Toolbox. This function calculates the t-statistic and the p-value for a two-sample t-test, assuming the samples are normally distributed and have equal variances (use the vartype parameter to specify "unequal" if needed).
Here's an example code snippet that demonstrates how to use the ttest function:
main.m436 chars15 lines
In this example, the ttest function tests the null hypothesis that the means of x and y are equal, against the alternative hypothesis that they are different. The output h is a logical value indicating whether to reject the null hypothesis at the 5% significance level. The output p is the p-value of the test, and stats contains the t-statistic and the degrees of freedom.
gistlibby LogSnag