Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. clear all;
  2. pocet=30;
  3. oblast=300;
  4. radius=50;
  5.  
  6.  
  7. matica=randi([0 oblast], 2,pocet);
  8.  
  9. for i=1:pocet
  10. x=matica(1,i);
  11. y=matica(2,i);
  12. txt = num2str(i)
  13. plot(x,y, 'r*');
  14. text(x+5,y-15,txt);
  15. axis([0 oblast 0 oblast]);
  16. hold on;
  17. end
  18. for i=1:pocet
  19. for j=1:pocet
  20. d=sqrt((matica(1,i)-matica(1,j))^2+(matica(2,i)- matica(2,j))^2)
  21. if(d <=radius && i ~=j)
  22. matica2(j,i)=1;
  23. plot([matica(1,i) matica(1,j),], [matica(2,i) matica(2,j)])
  24. end
  25. if(i==j)
  26. matica2(j,i) =0;
  27. end
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement