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

30 views (last 30 days)
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.

Accepted Answer

David Hill
David Hill on 23 Feb 2022
Edited: David Hill on 23 Feb 2022
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 Comments
Iliqe
Iliqe on 24 Feb 2022
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 on 24 Feb 2022
Edited: Iliqe on 24 Feb 2022
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));

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!