title: How to remove outliers?
body: <p>I have a matrix whose first column is X, second is Y and third is Z (a point cloud from Earth).
  Between them are outliers i.e. points that are very downward or very outside(because of systematic errors).
  I create a distance matrix and calculate distance of every point to all of the other points using below code:</p>
  
  <pre><code>xl = selected(:,1);
  yl = selected(:,2);
  zl = selected(:,3);
  distanceMatrix = zeros(size(selected,1));
  x = [xl(:)'; yl(:)'; zl(:)'];
  IP = x' * x;
  distanceMatrix = sqrt(bsxfun(@plus, diag(IP), diag(IP)') - 2 * IP);
  </code></pre>
  
  <p><code>selectedl</code> is my matrix. And calculate neighbors of each point and say: points that have 1 or 2 neighbors only are outliers.
  But: because of my matrix is too large (considering size of matrix), my laptop cannot process(out of memory: 4G!)</p>
  
  <p>Is there a method, function or code that calculate outliers automatically without calculate distance matrix?</p>