Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. clear;
  2. close all;
  3. clc;
  4. tic
  5. m = 500;
  6. aT = [];
  7. ad = [];
  8. gamma = 1.0e-5
  9. for i = [37:2:53]
  10. r = 6371 * 10^3;
  11. G = 6.674 * 10^-11;
  12. M = 5.972 * 10^24;
  13. g = (G * M)/(r^2);
  14. theta0 = i;
  15. ax = 0;
  16. ay = r;
  17. v0 = 2000;
  18. vx0 = v0*cosd(theta0);
  19. vy0 = v0*sind(theta0);
  20. x = 0;
  21. y = r;
  22. vx = vx0;
  23. vy = vy0;
  24. T = 0;
  25. dt = 0.01;
  26. at = 0;
  27. landed = 0;
  28. z = 1;
  29. while landed == 0
  30. z = z + 1;
  31. T = T + dt;
  32. xo = x;
  33. yo = y;
  34. x = x + vx * dt;
  35. y = y + vy * dt;
  36. d = sqrt(x^2 + y^2);
  37. alpha = atand(x/y);
  38. g = (G*M)/(d^2);
  39. gy = cosd(alpha) * g;
  40. gx = sind(alpha) * g;
  41. FgY = m * gy;
  42. FgX = m * gx;
  43. FricY = gamma*abs(vy)*vy;
  44. FricX = gamma*abs(vx)*vx;
  45. FnetY = FgY - FricY;
  46. FnetX = FgX - FricX;
  47. vy = vy - (gy * dt) - (FnetY / m)*dt; % This should substract gravity and friction from the velocity, not sure if this is correct.
  48. vx = vx - (gx * dt) - (FnetX / m)*dt; % Same for this line of code
  49. v = vx/sin(alpha);
  50. ax = [ax, x];
  51. ay = [ay, y];
  52. if d < r
  53. landed = 1;
  54. end
  55. end
  56.  
  57. aT = [aT, T];
  58. distance = (alpha/360) * 2 * pi * r;
  59. ad = [ad, distance];
  60.  
  61. fprintf('Checked for degree: %.0f\n', i)
  62.  
  63. end
  64. toc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement