I am attempting to find the location of highest datapoint density. I intend on removing datapoints that fall outside an oval and I'd like to attempt to automate the location (and size) of the oval such that it encompasses the area on the graph with the tightest distribution. This is because said data are real values and data that varies too much from this densly packed data is bad. For simplicity purposes, I uploaded only one dataset, but typically there are several. The data used in the plot is attached (clean_data.mat).
Plotting velocities against each other: Here I would like to position and size the oval such that is captures the tight band points. Currently I have to manually choose the location and size. Below, we can see that the oval is below the conecntration of points.
CODE: clean_data is attached to this post.
t = linspace(0,2*pi,5000);
theta = deg2rad(90);
a = 30; b = 15;
xv = U0 + a*cos(t)*cos(theta) - b*sin(t)*sin(theta);
yv = V0 + b*sin(t)*cos(theta) + a*cos(t)*sin(theta);
plot(xv,yv); hold on;
[in,on] = inpolygon(Uvec,Vvec,xv,yv);