Hi. 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?:
OPTION #1
Store X, Y and Z coordinates as separate n * 1 vectors (possibly within a structure?). This makes:
- Plotting simple:
plot3(X, Y, Z)
- Extracting individual points slightly more convoluted
N = [X(i), Y(i), Z(i)]
- Passing the entire set of points to a function expands the number of different arguments to pass.
OPTION #2
Store X, Y and Z coordinates as one n * 3 vector.
- Plotting is slightly harder:
plot3(XYZ(:, 1), XYZ(:, 2), XYZ(:, 3))
- Extracting individual points is easier:
N = XYZ(i, :)
- Passing entire set of points is easy - just one variable
Based on this, I suspect the second is the more conventional.
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:
OPTION #1
Store each X, Y and Z coordinate as an n * m matrix.
OPTION #2
Store all the points as an n * m * 3 matrix.
I would rather do the second here, but some options, like plotting become quite silly:
X = XYZ(:, :, 1);
Y = XYZ(:, :, 2);
Z = XYZ(:, :, 3);
plot3(X(:), Y(:), Z(:));
I have a feeling that there must be a convention for this, particularly in the vision and graphics community.