Attachment 'ttest_tutorial.m'

Download

   1 % T-test tutorial
   2 
   3 % Generate some toy data
   4 N = 20;
   5 d = [randn(N,1) randn(N,1)+0.7];      % Each column is one dataset
   6 
   7 % Paired-samples t-test
   8 [h,p,ci,stats] = ttest(d(:,1), d(:,2)); 
   9 
  10 % Format output
  11 if h
  12   fprintf('There was a significant effect of FACTOR (t(%d) = %2.2f, p = %0.2f).\n', ...
  13     stats.df,stats.tstat,p)
  14 else
  15   fprintf('There was no significant effect of FACTOR (p = %0.2f).\n',p)
  16 end
  17 
  18 % Independent samples t-test
  19 [h,p,ci,stats] = ttest2(d(:,1), d(:,2))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-12-12 16:07:10, 35.2 KB) [[attachment:ttest.png]]
  • [get | view] (2011-12-12 16:21:41, 0.5 KB) [[attachment:ttest_tutorial.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.