Plotting circles with some constraints from random points
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 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 Kommentare
Image Analyst
am 29 Jul. 2012
Bearbeitet: Image Analyst
am 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.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!