Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. clear
  2. m = 7.26 ; %%initial mass
  3. k = 0.47; %% drag coefficient of sphere
  4. Vx = 15;
  5. Vx2 = Vx
  6. Vz = 10;
  7. Vz2 = Vz
  8. V= sqrt(Vx^2 + Vz^2);
  9. area = 0.04
  10. airden = 1.2; %% air density at sea level
  11. fdrag = (airden*k*area)/2;
  12. nodragx(1) =0;
  13. nodragz(1) = 0;
  14. x(1) = 0;
  15. z(1)= 0;
  16. t(1) =0
  17. dt = 0.01
  18. i=1
  19. while (min(z)> -0.01)
  20. t = t + dt;
  21. i = i + 1;
  22. Ax = - ( fdrag / m ) * V * Vx;
  23. Az = -(9.8) - ( fdrag / m ) * V * Vz;
  24. Vx_new = Vx + Ax * dt;
  25. Vz_new = Vz + Az * dt;
  26. x(i) = x(i-1) + Vx_new * dt + 0.5 * Ax * dt^2;
  27. z(i) = z(i-1) + Vz_new * dt + 0.5 * Az * dt^2;
  28. Vx = Vx_new;
  29. Vz = Vz_new;
  30. end
  31. plot(x,z,'b'), hold on;
  32. Vx2 = 10;
  33. Vz2 = 15;
  34. nodragx(1) =0;
  35. nodragz(1) = 0;
  36. t(1) =0
  37. dt = 0.01
  38. i=1
  39. while (min(nodragz)> -0.01)
  40. t = t + dt;
  41. i = i + 1;
  42. Ax = 0;
  43. Az = -(9.8);
  44. Vx2_new = Vx2 + Ax * dt;
  45. Vz2_new = Vz2 + Az * dt;
  46. nodragx(i) = nodragx(i-1) + Vx2_new * dt + 0.5 * Ax * dt^2;
  47. nodragz(i) = nodragz(i-1) + Vz2_new * dt + 0.5 * Az * dt^2;
  48. Vx2 = Vx2_new;
  49. Vz2 = Vz2_new;
  50. end
  51. %plots the Projectile Motion with Drag
  52. plot(nodragx,nodragz,'r'), hold off; %plots the Projectile Motion without Drag
  53. xlabel('Horizontal Distance (m)'); %labels the x axis "Horizontal Distance (m)"
  54. ylabel('Vertical Distance (m)'); %Labels the y axis "Vertical Distance (m)"
  55. title('Projectile Motion Paths (Blue is with drag)');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement