I have x,y point data that I am trying to analyze in "swaths" or rectangles along the x-axis. I need to take the rectangle and subdivide it into equal areas, and count the number of areas that contain points.
Consider this example with a very small x,y dataset:
x = 10*rand(30,1);
y = 25*rand(30,1);
step = 1;
xmax = step*(ceil(max(x)/step));
centers = 0:step/2:xmax;
centers = centers';
ymax = step*(ceil(max(y)/step));
jj = 2;
xr = [centers(jj-1), centers(jj+1), centers(jj+1), centers(jj-1), centers(jj-1)];
yr = [ymax+step, ymax+step, 0-step, 0-step, ymax+step];
[in,on] = inpolygon(x,y,xr,yr);
num_points_example = sum(in);
So in this example, my blue rectangle is 26x1 units. To make equal areas, I need to keep the x-axis length the same (=1) and break the rectangle down into 26 square along the y-axis. My question is, how do I programmatically build a grid or mesh for this 26x1? Note that in the next step, I'll be subdividing it further (52x2), etc., always maintaining equal area. I only have the basic Matlab, no fancy toolboxes, R2018a.