Advertisement
Guest User

Untitled

a guest
May 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.93 KB | None | 0 0
  1.  
  2. function yp=f(t,y)
  3. // yp=f(t,y) désigne y'=f(t,y)
  4.     v0=4.50
  5.     g=9.81
  6.     L=0.6
  7.     c=(v0/L)^2-((2*g)/L)
  8.     yp=sqrt(c+((2*g)/L)*cos(t))
  9. endfunction
  10.  
  11. function y=Euler(f,a,b,y0,N)
  12. // Données : f est la fonction définie par y'=f(t,y)
  13. //          la fonction y étant définie sur l'intervalle [a,b]
  14. //          y0 est la condition initiale y(a)
  15. //          N est le nombre de points souhaités
  16. // Résultat :   renvoie un vecteur ligne dont les composantes sont
  17. //              les yk approchant y(a+kh) selon la méthode d'Euler
  18.     y=[y0];
  19.     t=a;
  20.     h=(b-a)/N
  21.     for i=1:N
  22.         y=[y,y(i)+h*f(t,y(i))]
  23.         t=t+h
  24.     end
  25. endfunction
  26.  
  27. a=0;
  28. b=12;
  29. y0=0;
  30. N=200;
  31. h=(b-a)/N;
  32. temps=[a:h:b];
  33. theta=[]
  34. theta=Euler(f,a,b,y0,N);
  35. thetap=[]
  36. thetap=f(temps,theta)
  37. clf
  38. plot(theta,thetap,"r")
  39. legend("Portrait de phase du pendule")
  40. xlabel("position angulaire en rad")
  41. ylabel("vitesse angulaire en rad/s")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement