Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. clear all
  2. close all
  3. lbox=20;
  4.  
  5. %random fluctuation
  6. eta = (2.*pi).*.1;
  7. vs=0.02;
  8. n=200;
  9. birdl=[1:n];
  10.  
  11.  
  12. axis([0 lbox 0 lbox])
  13. axis('square')
  14. hold on
  15. xb=rand(n,1).*lbox; %first possition
  16. yb=rand(n,1).*lbox; %first possition
  17. vxb = 1;
  18. vyb = 1;
  19.  
  20. for steps=1:5000;
  21. xb = xb + vxb;
  22. yb = yb+ vyb;
  23.  
  24. for bird1 = 1:n;
  25. %periodic boundary condition
  26. if(xb(bird1)<0);xb(bird1)=xb(bird1)+lbox; end
  27. if (yb(bird1)<0);yb(bird1)=yb(bird1)+lbox;end
  28. if (xb(bird1)>lbox);xb(bird1)=xb(bird1)-lbox;end
  29. if (yb(bird1)>lbox);yb(bird1)=yb(bird1)-lbox;end
  30.  
  31. end
  32. ang=eta.*(rand(n,1)-0.5);
  33.  
  34. vxb = vs.*cos(ang);
  35. vyb = vs.*sin(ang);
  36.  
  37. cla
  38.  
  39. set(gcf,'doublebuffer','on')
  40.  
  41. plot(xb,yb,'.b')
  42. %quiver(xb,yb,vxb,vyb,'b')
  43. drawnow
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement