Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. %Pflichtuebung 11
  2. %Daniel Jung 1411014
  3.  
  4. %Alle Variablen aus dem Speicher löschen
  5. clear all;
  6. clear fig;
  7.  
  8. %Parameter der Differentialgleichung festlegen:
  9. global m g c p d A
  10. m=0.145;
  11. g=9.81;
  12. c=0.5;
  13. p=1.2;
  14. d=0.5;
  15. A=pi/(4*d^2);
  16.  
  17. %Anfangs- und Endzeitpunkt festlegen:
  18. t0=0; %Anfangszeitpunkt
  19. tE=0.3; %Endzeitpunkt
  20. N=10000; %Anzahl der gespeicherten Datenpunkte
  21. deltatau=(tE-t0)/(N-1);
  22. tauspan=t0:deltatau:tE;
  23.  
  24. %Anfangsparameter abfragen
  25. alfarad=input('Abwurfwinkel in Grad: ');
  26. v0=input('Betrag der Anfangsgeschwindigkeit in m/s: ');
  27.  
  28. alfa=alfarad*(pi/180); %Grad in rad rechnen
  29.  
  30. x(1,1)=0; %Wert in x-Richtung
  31. x(2,1)=0; %Wert in y-Richtung
  32. x(3,1)=v0*cos(alfa); %Geschwindigkeit in x-Richtung
  33. x(4,1)=v0*sin(alfa); %Geschwindigkeit in y-Richtung
  34.  
  35. xstart=[x(1,1); x(2,1); x(3,1); x(4,1)]; %Vektor bilden
  36.  
  37. [t,X]=ode45(@wurf,tauspan,xstart); %Aufruf der Funktion
  38.  
  39. ta=t0;
  40. for n=1:N
  41. sx(n)=x(3,1)*ta(n);
  42. sy(n)=-1/2*g*ta(n)^2+x(4,1)*ta(n);
  43. ta(n+1)=ta(n)+deltatau;
  44. end
  45.  
  46. %Ergebnisse plotten
  47. figure(1)
  48. plot(X(:,1),X(:,2))
  49. hold on;
  50. plot(sx(1,:),sy(1,:))
  51. xlabel('Weite in m');
  52. ylabel('Höhe in m');
  53.  
  54. function f=wurf(t,x) %Funktion
  55. global m g c p A
  56. f(1,1)=x(3);
  57. f(2,1)=x(4);
  58. f(3,1)=-(c*p*A*sqrt(x(3)^2+x(4)^2)*x(3))/(2*m);
  59. f(4,1)=-((c*p*A*sqrt(x(3)^2+x(4)^2)*x(4))/(2*m))-g;
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement