Advertisement
Guest User

l22

a guest
Feb 26th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. clear all;
  2. ti = [10 10];
  3. for j = 1:length(ti)
  4. h = 0.1;
  5. t = 0:h:100;
  6. N = length(t);
  7. x = t;
  8. x(1) = ti(j);
  9. for i=2:N
  10. k1 = h*(abs(sin(t(i-1)))*x(i-1)-x(i-1)*x(i-1));
  11. k2 = h*(abs(sin(t(i-1)+1/2*h))*(x(i-1)+1/2*k1)-(x(i-1)+1/2*k1)*(x(i-1)+1/2*k1));
  12. k3 = h*(abs(sin(t(i-1)+1/2*h))*(x(i-1)+1/2*k2)-(x(i-1)+1/2*k2)*(x(i-1)+1/2*k2));
  13. k4 = h*(abs(sin(t(i-1)+h))*(x(i-1)+k3)-(x(i-1)+k3)*(x(i-1)+k3));
  14. x(i) = x(i-1)+1/6*(k1+2*k2+2*k3+k4);
  15. end
  16. plot(t,x,'g')
  17. hold on
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement