Advertisement
Lauda

Untitled

Nov 30th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.66 KB | None | 0 0
  1. function xp = kolok1zad2( t,x )
  2. b1 = 10;
  3. b2 = 20;
  4. m1 = 20;
  5. m2 = 10;
  6. k1 = 10;
  7. k2 = 20;
  8. k3 = 40;
  9.  
  10. y = (2*t).*(t>=0 & t<2) + (-2*t+8).*(t>=2 & t<4) + (2*t-8).*(t>=4 & t<6) + (-2*t+16).*(t>=6 & t<8) + (2*t-16).*(t>=8 & t<10) + (-2*t+24).*(t>=10 & t<12);
  11. f = min(y,3);
  12.  
  13. xp = [  x(3)
  14.         (1/m1)*(-2*b1*x(3)-k1*x(1)-k2*(x(1)-x(2)))
  15.         x(4)
  16.         (1/m2)*(k2*(x(1)-x(2))-f-k3*x(2)-b1*x(2))
  17.      ];
  18.  
  19. end
  20.  
  21. % [t,x] = ode23(@kolok1zad2, [0 12], [0; 0; 0; 0]);
  22. % plot(t,[x(:,1) x(:,4)])
  23. % a = size(t);
  24. % %distance shit
  25. % put1 = sum(abs(x(2:a(1),1) - x(1:a(1)-1:1)));
  26. % put2 = sum(abs(x(2:a(1),2) - x(1:a(1)-1:2)));
  27. % visepresao = max(put1,put2);
  28. % %w00t!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement