Create a coordinate system (x, y, z) matrix

23 次查看(过去 30 天)
The idea is to build a dataset of coordinates matrix with 3 coordinates along X, Y, and Z. The data which I have are:
% min and max coordinates of the dataset
Xmin = 388363.3 Xmax = 390229.2
Ymin = 3310114 Ymax = 3311144
Zmin = 2027.96 Zmax = 2889.9
% sub-block size along x, y, z:
dx = 20; dy = 20; dz = 10;
% number of layers along x, y, z:
nx = 95; ny = 53; nz = 88;
The resulting dataset starts with the min values of coordinates and goes up to max coordnates. The result is a matrix with 3 columns X, Y, and Z and the coordinates below, which correspond to the number of layers and sub-block size. And the result if you imagine will look like a big rectange with many subblocks.
I tried with a nested loop with some logic statements, but it is just produce the wrong coordinates. I think that I coded it incorrectly. If you need more info or details, please ask. Thank you for attention.

采纳的回答

David Hill
David Hill 2022-2-23
编辑:David Hill 2022-2-23
Xmin = 388363.3;
Xmax = 390229.2;
Ymin = 3310114;
Ymax = 3311144;
Zmin = 2027.96;
Zmax = 2889.9;
[X,Y,Z]=meshgrid(linspace(Xmin,Xmax,95),linspace(Ymin,Ymax,53),linspace(Zmin,Zmax,88));
scatter3(X(:),Y(:),Z(:));
  3 个评论
Iliqe
Iliqe 2022-2-24
Is it possible to build sub-blocks of exact necessary size? Because in the output the size varies, somewhere 19, somewhere 20, etc.
Iliqe
Iliqe 2022-2-24
编辑:Iliqe 2022-2-24
I found out, how to do this)
Just necessary change the code a bit:
[X,Y,Z]=meshgrid(linspace(Xmin,Xmin+dx*nx,nx+1),linspace(Ymin,Ymin+dy*ny,ny+1),linspace(Zmin,Zmin+dz*nz,nz+1));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by