Finding an equally spread subselection of XY-points
5 views (last 30 days)
Show older comments
I have a big list of 2D points with XY-coordinates. I want to find a subselection of those which are equally spread.
One of the methods I used for this is the follwing: First I make a grid with dx and dy as the desired distance between the points of the subselection. Then for every square of the grid, find the point closest to the center. This way I get a subselection.
You can see the result in attached graphs. The unfilled scatter plot are the input points and the filled scatter plot are the remaining output points of the sub selection.
As you can see in the second picture. This doesn't give a nice distribution in certain cases. Does any of you have an idea how to improve this? I don't really know any terms to google on to find algorithms.
Thanks in advance!
0 Comments
Answers (1)
Image Analyst
on 22 Jan 2018
Try this:
% Make 100 randomly located points between 0 and 100
x = 100 * rand(1, 100);
y = ones(1, length(x));
subplot(2, 1, 1);
plot(x, y, 'bs');
grid on;
% Make linearly spaced "desired" locations
% from 10 to 90 spaced every 10.
desiredx = 10:10:90;
% Find which of the actual data is closest to the desired data.
for k = 1 : length(desiredx)
[minDistance, index(k)] = min(abs(x - desiredx(k)));
end
% Extract the closest points.
closestx = x(index);
y = ones(1, length(closestx));
% Plot them
subplot(2, 1, 2);
plot(closestx, y, 'rs');
grid on;
4 Comments
Image Analyst
on 22 Jan 2018
Why wouldn't it work in 2-D? I didn't have your y values so I just used 1 but I don't see why it wouldn't work with any y values. Attach your data if you want.
Be aware that the interparc goes for uniform distances along the arc, not just uniform in the x or y direction. This is a different concept. You have to decide which way you want it.
See Also
Categories
Find more on Historical Contests 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!