Plot points with minimal distance

Hello friends, please a i need i make 1000x1000 place and plot three points with color on this place. But distance between points must be minimal 400metres.
Thank you :)

4 comentarios

darova
darova el 1 de Oct. de 2019
Please show us your attempts
Jon
Jon el 1 de Oct. de 2019
Editada: Jon el 1 de Oct. de 2019
Please explain further, it is not clear what you are trying to do. What is a "place"?How does the scale in metres somehow relate to your array size. Can you put these points anywhere as long as they are a certain distance apart? There are infinitely many other ways of putting three points that are more than x away from each other in a two dimensional plane. Three points put all along the same line are at least x units away from each other as long as the interval between the points is greater than x. Another simple possibility is to put them at the vertices of an equilateral triangle whose sides are at least x.
Richard Hojstric
Richard Hojstric el 1 de Oct. de 2019
So, i need to do :
In Matlab, render an area of ​​1000 x 1000metres. In this area plot 3 points random (i think), with some color. Distance between this poitns should be minimum 400m.
And of the end display its x and y coordinates to each point.
I think it a simple but i have matlab last year :D
Something like on picture but i need it 1000x1000 area and with distance :)
test.png
Thanks.
Richard Hojstric
Richard Hojstric el 1 de Oct. de 2019
But this three points can be set permanently not random :) its easier. But how set distance ?

Iniciar sesión para comentar.

Respuestas (1)

Shadaab Siddiqie
Shadaab Siddiqie el 26 de Ag. de 2020
From my understanding you want to plot 3 random points, each at a distance of at least 400units form other 2 points, in a plot of 1000x1000 units. You could select first point randomly. Then for second point you can keep selecting a point randomly until the condition satisfies. Similarly, do it for the third point.
% randomly choose point1
point1 = [randi(1000),randi(1000)];
% choose point2 such that distance between point1 and point2 is greater than 400
point2 = [randi(1000),randi(1000)];
while pdist([point1;point2],"euclidean")<=400
point2 = [randi(1000),randi(1000)];
end
% choose point3 such that distance between point3 and point1 is greater than 400 and
% distance between point3 and point2 is greater than 400
point3 = [randi(1000),randi(1000)];
while pdist([point1;point3],"euclidean")<=400 || pdist([point2;point3],"euclidean")<=400
point3 = [randi(1000),randi(1000)];
end
%plot the points
hold on
plot([point1(1) point2(1) point3(1)],[point1(2) point2(2) point3(2)],'.b',"Marker","o");
xlim([0 1000])
ylim([0 1000])
Hope this helps.

Categorías

Etiquetas

Preguntada:

el 1 de Oct. de 2019

Respondida:

el 26 de Ag. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by