Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- pocet=30;
- oblast=300;
- radius=50;
- matica=randi([0 oblast], 2,pocet);
- for i=1:pocet
- x=matica(1,i);
- y=matica(2,i);
- txt = num2str(i)
- plot(x,y, 'r*');
- text(x+5,y-15,txt);
- axis([0 oblast 0 oblast]);
- hold on;
- end
- for i=1:pocet
- for j=1:pocet
- d=sqrt((matica(1,i)-matica(1,j))^2+(matica(2,i)- matica(2,j))^2)
- if(d <=radius && i ~=j)
- matica2(j,i)=1;
- plot([matica(1,i) matica(1,j),], [matica(2,i) matica(2,j)])
- end
- if(i==j)
- matica2(j,i) =0;
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement