title: Most conventional method for storing XYZ data in MATLAB
body: <p>I have a large amount of data to import in to MATLAB, representing location of points in cartesian space. Which of the following is the most conventional for storing and processing standard XYZ data?:</p>
  
  <p><strong>OPTION #1</strong></p>
  
  <p>Store X, Y and Z coordinates as separate n * 1 vectors (possibly within a structure?). This makes:</p>
  
  <ul>
  <li>Plotting simple: <code>plot3(X, Y, Z)</code></li>
  <li>Extracting individual points slightly more convoluted <code>N = [X(i), Y(i), Z(i)]</code></li>
  <li>Passing the entire set of points to a function expands the number of different arguments to pass.</li>
  </ul>
  
  <p><strong>OPTION #2</strong></p>
  
  <p>Store X, Y and Z coordinates as one n * 3 vector.</p>
  
  <ul>
  <li>Plotting is slightly harder: <code>plot3(XYZ(:, 1), XYZ(:, 2), XYZ(:, 3))</code></li>
  <li>Extracting individual points is easier: <code>N = XYZ(i, :)</code></li>
  <li>Passing entire set of points is easy - just one variable</li>
  </ul>
  
  <p>Based on this, I suspect the second is the more conventional. </p>
  
  <hr>
  
  <p>However, some of the data I'll be processing is harder, as it is read in in grid form, where the format of the grid is important. By this, I mean that the raw form for the data is as a n * m * 3 matrix, instead of an (n*m) * 3 matrix. The fact that point X(i, j) is next to point X(i, j+1) is important. Again, two options are presented:</p>
  
  <p><strong>OPTION #1</strong></p>
  
  <p>Store each X, Y and Z coordinate as an n * m matrix.</p>
  
  <p><strong>OPTION #2</strong></p>
  
  <p>Store all the points as an n * m * 3 matrix.</p>
  
  <p>I would rather do the second here, but some options, like plotting become quite silly:</p>
  
  <pre><code>X = XYZ(:, :, 1);
  Y = XYZ(:, :, 2);
  Z = XYZ(:, :, 3);
  plot3(X(:), Y(:), Z(:));
  </code></pre>
  
  <p>I have a feeling that there must be a convention for this, particularly in the vision and graphics community.</p>