sem.m 386 B

1234567891011121314151617
  1. function sem=sem(data,stdWeight)
  2. % calculate standard error of the mean in the 1st dim
  3. % stdWeight==0: N-1
  4. % stdWeight==1: N
  5. if iscell(data)
  6. if size(data,2)>size(data,1)
  7. data=data';
  8. end
  9. for i=1:length(data)
  10. sem(i,1)=std(data{i,1},stdWeight,1)/sqrt(size(data{i,1},1));
  11. end
  12. else
  13. sem=std(data,stdWeight,1)/sqrt(size(data,1));
  14. end
  15. end