nansem - Compute standard error of the mean (SEM), ignoring NaNs. USAGE s = nansem(x) s vector or matrix over which the sem should be computed
0001 function s = nansem(x) 0002 0003 %nansem - Compute standard error of the mean (SEM), ignoring NaNs. 0004 % 0005 % USAGE 0006 % 0007 % s = nansem(x) 0008 % 0009 % s vector or matrix over which the sem should be computed 0010 0011 % Copyright (C) 2008-2011 by Michaƫl Zugaro 0012 % 0013 % This program is free software; you can redistribute it and/or modify 0014 % it under the terms of the GNU General Public License as published by 0015 % the Free Software Foundation; either version 3 of the License, or 0016 % (at your option) any later version. 0017 0018 if nargin < 1, 0019 error('Incorrect number of parameters (type ''help <a href="matlab:help nansem">nansem</a>'' for details).'); 0020 end 0021 0022 if ~isdmatrix(x) & ~isdvector(x), 0023 error('Incorrect input - use vector or matrix (type ''help <a href="matlab:help nansem">nansem</a>'' for details).'); 0024 end 0025 0026 if any(size(x)==1), x = x(:); end 0027 0028 n = sum(~isnan(x)); 0029 s = nanstd(x)./sqrt(n);