measure distnaces between 50 points inside circle
1 view (last 30 days)
Show older comments
i have this code to generate 50 random points inside a circle %%// Plot the circle x = linspace(-sqrt(10),sqrt(10)); y1 = sqrt(10-x.^2); y2 = -sqrt(10-x.^2); plot(x,y1,x,y2) axis equal
%%// Choose from 1000 random point pairs N = 1000; %%// Radius of circle radius = sqrt(10);
%%// Create a random point matrix Nx2 points_mat = [ radius*2*(rand(N,1)-0.5) radius*2*(rand(N,1)-0.5)];
%%// Select the first 50 pairs that lies inside circle ind1 = find(sqrt( points_mat(:,1).^2 + points_mat(:,2).^2 )<radius); points_mat=points_mat(ind1(1:50),:);
%%// Plot the 50 points on the circle hold on text(0,0,'x Center') %%// Center text(points_mat(:,1),points_mat(:,2),'o') %%// 50 points i want to measure distance between every point in the circle and the rest of the points and every point and the center (if distance between the point and the other point is smaller than distance between each point and the center then make a red line between the two points , if distance between two points is larger than distance between one point and the center but greater than distance between the other point and the center then make blue line between two points then if distance between 2 points is greater than distance between each point and the center then make a green line between teach point and the center
<<
>>
like this pseudo code 01: FOR all nodes j 02: FOR all nodes i except node j 03: IF distance(j to center) < distance(j to i) AND 04: distance(i to cell center) < distance(j to i) 05: THEN there's a red link from node i to node j 06: ELSE IF distance(j to cell center) < distance(j to i) 07: THEN there's a blue link from node i to node j 08: else node i has a green link with the center 09: END if 10: END inner for-loop –
0 Comments
Answers (1)
Image Analyst
on 31 Mar 2014
Is this any different than the 3 other messages you posted: http://www.mathworks.com/matlabcentral/answers/contributors/5174743-menna/questions You have totally ignored the people who answered those questions, so that makes me think people would be wasting their time to help you in this question. Please clarify.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots 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!