Advertisement
Guest User

Untitled

a guest
May 4th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. dt=0.005;
  2. g=9.80665;
  3. C=0.1;
  4. m=10;
  5. tcalkowity=10000;
  6. n=1;
  7. nmax=0;
  8. nkoncowe=0;
  9. tmax=0;
  10. tkoncowe=0;
  11. ymax=0;
  12.  
  13. t=zeros(tcalkowity,1);
  14. V=zeros(tcalkowity,1);
  15. y=zeros(tcalkowity,1);
  16. V(1)=500;
  17. y(1)=0;
  18.  
  19. while y(n,1)>=0
  20. t(n+1)=t(n)+dt;
  21. V(n+1)=V(n)+dt*(-g-(C*abs(V(n))*V(n))/m);
  22. y(n+1)=y(n)+dt*V(n);
  23. n=n+1;
  24. nkoncowe=n-1;
  25. end
  26.  
  27. for n=1:nkoncowe
  28. if y(n,1)<=y(n+1,1)
  29. ymax=y(n+1,1);
  30. nmax=n+1;
  31. end
  32. end
  33.  
  34. tmax = nmax*dt;
  35. tkoncowe = nkoncowe*dt;
  36.  
  37. plot(t,y)
  38. tmax
  39. tkoncowe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement