Dear
I need to draw a figure that contains 20 randomized points in an area [-100 100]. If we have the distance between two points less than 6 meters .It is necessary to repeat the randamization of the points
Then each point must know its distance from the other points
close all;clear all;clc;set(gca,'xtick',-100:20:100);set(gca,'ytick',-100:20:100); axis([-100 100 -100 100]);X = 200 * rand(1,20) - 100;Y = 200 * rand(1,20) - 100;plot(X, Y, 'b*');grid onhold ondatacursormode%calculate the distance between a point and the other points
%exemple the distance between (A and B) & (A and C) &(A and D) & (A and E)...
%also (B and A) & (B and C) &(B and D) & (B and E).......
distance=[];for i=1:20dist = sqrt((X(i)-X(:)).^2+(Y(i)-Y(:)).^2); distance=[distance dist];end
thank you
[Moved from asnwer section:]
My question is to display an imege of 20 randomized points and if we have the distance between two points <6meters I repeat the randomization of these two points. And after all if the condition is fulfilled. Each point must know the distance with the other 19 points so I want to find a distance matrix in the workspace that contains 20 row and 20 column as indicated my code.
It is varied that in my code I find in the workspace the matrix distance that is to say each point know its distance with respect to the other points but the condition so that if the distance between two points is <6meters is not realized
I would like my question to be clear
Best Answer