title: Correct use of pdist in Matlab
body: <p>I have a point-cloud, for which i want to calculate the distance between all individual points in Matlab (preferably without duplicates).</p>
  
  <p>The matrix with the coordinates is formatted as: <code>points [ p x n x d ]</code>. Where <code>p = 1</code> (for now), n is as large as the number of points and d as large as the number of dimensions (3 in this case).</p>
  
  <p>This is the data i have:</p>
  
  <ul>
  <li><code>points(:,:,1) = 1 2 3</code></li>
  <li><code>points(:,:,2) = 4 5 6</code></li>
  <li><code>points(:,:,3) = 7 8 9</code></li>
  </ul>
  
  <p>So i have three points in three dimensions. Now using pdist, i have tried to calculate the euclidian distance between each point using <code>distances = pdist(points(:,1:3));</code> and <code>distances = pdist(X(:,:,1:3));</code> But both just return an empty matrix.</p>
  
  <p>Does anyone know how to use <code>pdist</code> to calculate these distances? It should return 3 distances, instead of 0, but i must be doing something wrong.</p>
  
  <hr>
  
  <p><em>Btw. this question is a follow up to <a href="https://stackoverflow.com/questions/9483363/simplifying-the-use-of-meshgrid-in-matlab">this</a> one. I asked it in the comments at first, but thought it deserved a new question because it is a considerable expansion of the original question.</em></p>