Advertisement
osipyonok

SolveDiff

Mar 26th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.30 KB | None | 0 0
  1. function res = SolveDiff(A, cur)
  2. res = cur;
  3. t = 0.2;
  4. for i=1:251
  5.     k1 = t * A * cur;
  6.     k2 = t * A * (cur + k1 / 2.0);
  7.     k3 = t * A * (cur + k2 / 2.0);
  8.     k4 = t * A * (cur + k3);
  9.     next = cur + (1.0 / 6.0) * (k1 + 2.0 * k2 + 2.0 * k3 + k4);
  10.     res = [res, next];
  11.     cur = next;
  12. end;
  13.  
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement