Global Index (short | long) | Local contents | Local Index (short | long)
v = var_nan(mat1);
function v = var_nan ( mat1 ) ; This function computes the variance of each column of mat1, which may contain NaNs. Elements of mat1 that are NaN's are ignored. It is assumed that the variance will be taken along the column dimension of mat1.
This function calls | This function is called by |
---|---|
function v = var_nan(mat1); [m1, n1] = size(mat1); v = NaN*ones(1, n1); mat1 = mat1 - ones(m1, 1)*mean2(mat1); for i = 1:n1; kp1 = find(~isnan(mat1(:,i))); if ~isempty(kp1); v(i) = mat1(kp1,i)'*mat1(kp1,i) / (length(kp1)-1); end end