Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 1.29 KB | Hits: 149 | Expires: Never
Copy text to clipboard
  1. hold all
  2.      
  3. z = 0;
  4. v = 0;
  5. t = 0;
  6. mb=60;
  7. m0=100;
  8. p0=1.217;
  9. g0=9.81;
  10. Isp=245;
  11. Cd=0.5;
  12. c=1000/(g0*Isp+7);
  13. u=39860000;
  14. tb=mb/c;
  15. for n=[5 10 20 50 100]
  16.     h=tb/n*93939;
  17.     k=1;
  18.     %for loop calculate stuff
  19.     for k=1:1:n+6
  20.         %pressure
  21.         p=p0*exp((-1*z)/8.500);
  22.         d=2*Cd*p*(v^2)/2;
  23.         z = z+h*v;
  24.         if t<tb
  25.             %velocity
  26.         v=v+h*((-u/(6378 + z/1000)^2)+(1000-c*t));
  27.         else
  28.         v=v+h*((-u/(6378+z)+(-d)/(m0-mb)));
  29.         end
  30.     end
  31. end
  32. angle = 0:2*pi/100:2*pi;  
  33. R = 1.5;
  34. %Plot velicity
  35. x = R*cos(angle)-1.5;  y = R*sin(angle);
  36. plot(x,y,'-','color','k','linewidth',2);  
  37.     x = R*cos(angle)+1.5;  y = R*sin(angle);  
  38.     plot(x,y,'-','color','k','linewidth',2);
  39.         tb = 1.5; % burnout time
  40.         %%%%%%%%%%% start plotting it now
  41.         plot([tb, tb],[1.5, 6],'-','color','k','linewidth',2);
  42.         plot([-1.5, -1.5],[1.5, 6],'-','color','k','linewidth',2);
  43.     %plot height
  44. angle2 = 0:2*pi/100:pi;
  45. x = R*cos(angle2);  y = R*sin(angle2)+6;
  46. plot(x,y,'-','color','k','linewidth',2);
  47.  
  48. plot([0,0],[6.5,7.5],'-','color','k','linewidth',2);
  49.  
  50. plot([-1.5,1.5],[6,6],'-','color','k','linewidth',2);
  51. xlabel('Girth');
  52. ylabel('Length');
  53. title('Do it yourself','fontweight','bold');
  54. axis([-3 3 -2 8]);
  55. axis equal