Guest User

Untitled

a guest
Apr 28th, 2015
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Use eradode(0.0075,0.0055,0.09,0.0001,10,1,500,0,0)
  2.  
  3.  
  4. function [z] = eradode(a,b,ze,d,Ti,dt,s1,z1,r1)
  5. % This function will take as inputs, the initial value of the 3 classes.
  6. % It will then apply Eulers method to the problem and churn out a vector of
  7. % solutions over a predetermined period of time (the other input).
  8. % Function Inputs: s1, z1, r1 - initial value of each ODE, either the
  9. % actual initial value or the value after the
  10. % impulse.
  11. % Ti - Amount of time between inpulses and dt is time step
  12. % Created by Philip Munz, November 21, 2008
  13. k = Ti/dt;
  14. %s = zeros(1,n+1);
  15. %z = zeros(1,n+1);
  16. %r = zeros(1,n+1);
  17. %t = 0:dt:Ti;
  18. s(1) = s1;
  19. z(1) = z1;
  20. r(1) = r1;
  21. for i=1:k
  22. s(i+1) = s(i) + dt*(-b*s(i)*z(i));
  23. z(i+1) = z(i) + dt*(b*s(i)*z(i) -a*s(i)*z(i) + ze*r(i));
  24. r(i+1) = r(i) + dt*(a*s(i)*z(i) +d*s(i) - ze*r(i));
  25. end
  26. %plot(t,z)
Advertisement
Add Comment
Please, Sign In to add comment