Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. x(1)= 600;
  2. y(1)= 60;
  3.  
  4. gB = 1;
  5. sterberateB = [0.03 0.05 0.075 0.09];
  6. gR = 0.002;
  7. sR = 1;
  8.  
  9.  
  10. for sB = sterberateB
  11.  
  12. f=@(t,x,y) gB*x-sB*x*y;
  13. g=@(t,x,y) gR*x*y-sR*y;
  14.  
  15. end
  16.  
  17. schrittweite = [0.2 0.1 0.05 0.001];
  18.  
  19. for h = schrittweite
  20. t = 0:h:80;
  21.  
  22. for i=1:(length(t)-1)
  23. k1=f(t(i),x(i),y(i));
  24. l1=g(t(i),x(i),y(i));
  25.  
  26. k2=f(t(i)+h/2,(x(i)+0.5*k1*h),(y(i)+(0.5*l1*h)));
  27. l2=g(t(i)+h/2,(x(i)+0.5*k1*h),(y(i)+(0.5*l1*h)));
  28.  
  29. k3=f(t(i)+h/2,(x(i)+0.5*k2*h),(y(i)+(0.5*l2*h)));
  30. l3=g(t(i)+h/2,(x(i)+0.5*k2*h),(y(i)+(0.5*l2*h)));
  31.  
  32. k4=f(t(i)+h, (x(i)+k3*h), (y(i)+l3*h));
  33. l4=g(t(i)+h, (x(i)+k3*h), (y(i)+l3*h));
  34.  
  35. x(i+1)= x(i) + h*(k1 + 2*k2 + 2*k3 +k4)/6;
  36. y(i+1)= y(i) + h*(l1 + 2*l2 + 2*l3 +l4)/6;
  37.  
  38.  
  39. end
  40. plot(t,x,t,y)
  41. axis([0 100 1 3000])
  42. hold on
  43. end
  44.  
  45. clear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement