daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [y,t] = euler(z, yz, y0, t0, dt, steps)
  2. ys = [y0];
  3. ts = [t0];
  4. for i=2:steps
  5.     ts(i) = ts(i-1)+dt;
  6.     if yz-ys(i-1)>0
  7.       ys(i) = ys(i-1)+dt*((yz*3)-3*ys(i-1))+z;
  8.     else
  9.       ys(i) = ys(i-1)+dt*(5-3*ys(i-1))-z;
  10.     end
  11. end
  12. y = ys;
  13. t = ts;
  14. endfunction
  15.  
  16. [y,t] = euler(0.2,13,0,0,0.1, 100);
  17. plot(t,y);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top