Plotting circles with some constraints from random points
Show older comments
Hey guys,
i have randomly generated n-by-2 matrix which have (x,y) coordinates in it.
after sorting them like sort(coordinates,'rows')
i want to plot them starting from the first to last one if the distance between them is less than some distance d.
To make it more clear
the program will plot (or put the coordinates in another matrix or do something else) the first coordinates because there will be notting to compare with , than it will look the distance beetween coordinates(2,:) and coordiante(1,:) and plot it if the distance is more than d. then for the third one first it will look the first and second.(Plotted ones)
so a nth coordinates will be compared with all coordinates from 1 to n IF THEY ARE PLOTTED.
I know it become a long text but i hope i explained it clear enough.
And thank you everyone for your help.
Accepted Answer
More Answers (1)
Image Analyst
on 29 Jul 2012
Seems very easy and straightforward. Were you unable to do it with a pair of nested for loops? What happened when you tried the obvious brute force method:
for k1 = 1 : n
for k2 = 1 : k1
% Compare to others that went before it.
% Calc distance, etc.
end
end
Whas there some error or something?
2 Comments
Image Analyst
on 29 Jul 2012
Edited: Image Analyst
on 29 Jul 2012
You're not comparing the next possible site to all prior commissioned sites. You just haven't thought it through clearly enough. See the Answer below.
Categories
Find more on Loops and Conditional Statements 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!