1 | #!/usr/bin/env octave |
---|

2 | |
---|

3 | |
---|

4 | function ys = euler(f,t,y,h) |
---|

5 | t0=t(1); tn=t(2); |
---|

6 | tx=t0; ys=zeros(ceil((tn-t0)/h),length(y)); |
---|

7 | ys(1,:)=y; i=1; |
---|

8 | while (tx<tn) |
---|

9 | i = i+1; tx=tx+h; |
---|

10 | ys(i,:) = ys(i-1,:)' + (h * feval(f,tx,ys(i-1,:))); |
---|

11 | endwhile |
---|

12 | endfunction |
---|

13 | |
---|

14 | ## Hodgkin-Huxley model driver for Octave |
---|

15 | |
---|

16 | hh_defs = "hh-substrate.m"; |
---|

17 | ##hh_defs = "hh-superstrate.m"; |
---|

18 | |
---|

19 | autoload ("hodgkin_huxley", hh_defs ); |
---|

20 | autoload ("hodgkin_huxley_init", hh_defs ); |
---|

21 | |
---|

22 | y0 = hodgkin_huxley_init(-65) |
---|

23 | |
---|

24 | #t = linspace(0,100,1000); |
---|

25 | #lsode_options("initial step size",0.001); |
---|

26 | #y = lsode ("hodgkin_huxley", y0, t); |
---|

27 | |
---|

28 | #t = [0,100]; |
---|

29 | #P = odeset ('InitialStep', 0.0001 ); |
---|

30 | #[t, y] = odesx (@hodgkin_huxley, t, y0, P); |
---|

31 | |
---|

32 | t = [0,10]; |
---|

33 | y = euler (@hodgkin_huxley, t, y0, 0.001) |
---|

34 | |
---|

35 | save "-ascii" "hodgkin_huxley.dat" y; |
---|