Plotting circles with some constraints from random points
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Image Analyst
2012년 7월 29일
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
Image Analyst
2012년 7월 29일
편집: Image Analyst
2012년 7월 29일
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.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!