I'll share a couple thoughts about how I would try to approach this.
In order to create a contour plot, MATLAB requires the inputs to be matrices. Each row corresponds to a value on the Y axis, and each column corresponds to a value on the X axis. This means the data needs to be arranged in an evenly spaced grid.
For your data, that means dividing the XY plane into bins, and counting the number of points in each bin. You can do this using histcounts2. This returns a mxn matrix where the rows corespond to your X bins, and the columns correspond to your Y bins.
Next, create X and Y matrices, also mxn, using meshgrid.
Finally, create your contour plot.
Here's a rough example using random numbers.
x = (randn(20000,1)*40)+200;
y = abs(randn(20000,1))*20;
N = histcounts2(x,y,Xedges,Yedges);
[X,Y] = meshgrid(mean([Xedges(1:end-1);Xedges(2:end)],1),...