Advertisement
kanciastopantalones

REszesc

Oct 20th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. rstanu6E = function(t, x, a){
  2. u = 1
  3. dx1=(1/20)*u - (1/20)*x[2]
  4. dx2=(3/20)*u + x[1] - (9/20)*x[2]
  5. list(c(dx1,dx2))
  6. }
  7.  
  8. rstanu6Esin = function (t, x, a){
  9. u=sin(0.5*t)
  10. dx1=u-x[2]/20
  11. dx2=9*u-((9*x[2])/20)+x[1]
  12. list(c(dx1,dx2))
  13. }
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. rstanu6E = function(t, x, a){
  22. u = 1
  23. dx1=(1/20)*u - (1/20)*x[2]
  24. dx2=(3/20)*u + x[1] - (9/20)*x[2]
  25. list(c(dx1,dx2))
  26. };
  27.  
  28. rstanu6Esin025t = function (t, x, a){
  29. u=0.025*t
  30. dx1=(1/20)*u - (1/20)*x[2]
  31. dx2=(3/20)*u + x[1] - (9/20)*x[2]
  32. list(c(dx1,dx2))
  33. }
  34.  
  35. rstanu6Esin = function (t, x, a){
  36. u=sin(0.5*t)
  37. dx1=(1/20)*u - (1/20)*x[2]
  38. dx2=(3/20)*u + x[1] - (9/20)*x[2]
  39. list(c(dx1,dx2))
  40. }
  41.  
  42. eksp1 = function(x0){
  43. t = seq(0, 10, 0.01)
  44. out1 = ode(x0, t, rstanu6E, NULL)
  45. out2 = ode(x0, t, rstanu6Esin025t, NULL)
  46. out3 = ode(x0, t, rstanu6Esin, NULL)
  47. par(mfrow=c(2,2))
  48. y1 = out1[,3]
  49. y2 = out2[,3]
  50. y3 = out3[,3]
  51. plot(t,y1,type='l',col='red',xlab='t',ylab='y',main='wykres y(t) u = 1')
  52. lines(t,y2,type='l',col='blue',xlab='t',ylab='y',main='wykres y(t) u = 0,025t')
  53. lines(t,y3,type='l',col='green',xlab='t',ylab='y',main='wykres y(t) u = sin(0,5t)')
  54. #plot(out1[,2],out1[,3],type='l',col='blue',xlab='x1',ylab='x2',
  55. # main='portret fazowy')
  56. }
  57. eksp1(c(0,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement