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!