The most common method of storing XYZ data in MATLAB

I have a large amount of data to import into MATLAB, representing the location of points in Cartesian space. Which of the following is the most common for storing and processing standard XYZ data ?:

OPTION number 1

Save X, Y, and Z coordinates as separate n * 1 vectors (perhaps inside the structure?). It does:

  • Simple laying: plot3(X, Y, Z)
  • Extracting individual points is a bit more confusing N = [X(i), Y(i), Z(i)]
  • Passing the entire set of points to a function expands the number of arguments passed.

OPTION number 2

Save the X, Y, and Z coordinates as one n * 3 vector.

  • Density is a bit trickier: plot3(XYZ(:, 1), XYZ(:, 2), XYZ(:, 3))
  • Extracting individual points is easier: N = XYZ(i, :)
  • Passing the entire set of points is easy - just one variable

Based on this, I suspect that the second is more conditional.


, , , , . , n * m * 3, (n * m) * 3. , X (i, j) X (i, j + 1). , :

β„– 1

X, Y Z n * m.

β„– 2

n * m * 3.

, , , :

X = XYZ(:, :, 1);
Y = XYZ(:, :, 2);
Z = XYZ(:, :, 3);
plot3(X(:), Y(:), Z(:));

, , .

+3
3

, . - , .

, plot3d. , nx3 ( , ), plot3, .

% =============================
function h = plot3d(data,varargin)
% plots 3-d data (more help is good here)
h = plot3(data(:,1),data(:,2),data(:,3),varargin{:});
if nargout == 0
  clear h
end
% =============================

, .

nx3. , , . , , delaunay .

Matlab, , , , , .

+3

n x 3 ( 3 x n) , . , , , , , , , , . plot3.

, , "", !

0

. 3 x n x m ( n x m x 3), :

  • N(:, i, j)
  • All X, Y, or Z coordinates can be extracted as vector s N(1, :), N(2, :)orN(3, :)
  • All data can be immediately transferred to the function.
  • Saves the original data format.
  • I can easily convert to 3 x (n * m) matrix with N(:, :)

Does this sound like a suitable solution?

0
source

Source: https://habr.com/ru/post/1764363/


All Articles