source: project/release/3/nemo/trunk/examples/hh-driver.m @ 13052

Last change on this file since 13052 was 13052, checked in by Ivan Raikov, 12 years ago

Save.

File size: 774 bytes
Line 
1#!/usr/bin/env octave
2
3
4function 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
12endfunction
13
14## Hodgkin-Huxley model driver for Octave
15
16hh_defs = "hh-substrate.m";
17##hh_defs = "hh-superstrate.m";
18
19autoload ("hodgkin_huxley", hh_defs );
20autoload ("hodgkin_huxley_init", hh_defs );
21
22y0 = 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
32t = [0,10];
33y = euler (@hodgkin_huxley, t, y0, 0.001)
34
35save "-ascii" "hodgkin_huxley.dat" y;
Note: See TracBrowser for help on using the repository browser.