MATLAB: How to extract the coordinates of all the points in the region.

plotting

I have written a code which shows a particular region of interest (see figure). I now want to get the cartesian coordinates (x,y,z) of each and every point in this region.
Code is as following:
clc;
close all;
clear all;
x = linspace(0.5,49.5,100);
y = linspace(0,4.8,100);
z = linspace(2.5,4.4,100);
[X,Y,Z]=meshgrid(x,y,z);
v = X.*Y.*Z; %Creating a volume region
% Data defining a surface
[xs, ys] = meshgrid(x,y);
zs = 2.5+(tand(22).*ys);%Defining the slope of the roof
% Slice along it
slice(X, Y, Z, v, xs, ys, zs);
colorbar

Best Answer

If you want the coordinate list as a N-by-3 list of (x,y,z) coordinates, do this:
coordinateList = [X(:), Y(:), Z(:)];