www.gusucode.com > stats 源码程序 matlab案例代码 > stats/OneSidedtTestExample.m

    %% One-Sided t-Test  

%% 
% Load the sample data. Create a vector containing the first column of the
% students’ exam grades data. 
load examgrades
x = grades(:,1);  

%% 
% Test the null hypothesis that the data comes from a population with mean
% equal to 65, against the alternative that the mean is greater than 65. 
h = ttest(x,65,'Tail','right') 

%%
% The returned value of |h = 1| indicates that |ttest| rejects the null
% hypothesis at the 5% significance level, in favor of the alternate hypothesis
% that the data comes from a population with a mean greater than 65.