2012-10-04 90 views
0

我試圖用ode45模擬神經元的Morris-Lecar模型。Matlab ode45基本設置

我在初始化ode45調用時遇到問題,文檔無法幫助我。我知道我必須通過函數調用ode45,並從我的主腳本中調用該函數。

我對一般ODE的掌握有限,似乎無法理解初始化ODE45調用所需的語法。

此外,我被指示爲變量'pulse'使用時間範圍,但是在函數中沒有時間範圍的輸入(這似乎是一個變量,不是固定的)主腳本並將其他函數發送到ode45函數。提供給ode45的函數也有時間輸入,但是我再也不知道如何輸入時間範圍。說明非常清楚,主腳本中使用的函數不會佔用任何時間變量。

如果您可以指出我在初始化過程中發生的任何明顯錯誤,我們將非常感激。

電流(下同)版本的錯誤代碼是如下:

Error using ODEequation (line 89) 
Not enough input arguments. 

Error in odearguments (line 88) 
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. 

Error in ode45 (line 114) 
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ... 

Error in ODEquestion (line 32) 
[t Vm]=ode45(@ODEequation,[-20 20],[-30, 0.1]',[],constants, stim_on, stim_off, amp); 

Error in YoonS_Lab3_EBME308_Fall2012 (line 355) 
[t Vm] = ODEquestion(20,100,30) 

我覺得這要追溯到我的不存在的,但需要時間投入。

問題涉及

Cm * dVm/dt = -Gm(Vm-Vrest) - Gca Minf (Vm - Eca) - Gk w(Vm - Ek) + pulse(t) 

dw/dt = (wInf - w)/Tau-w; 

wInf = (1+tanh(Vm/30))/2; 
mInf = (1+tanh(Vm+1))/2; 
Tau-w = 5/ (cosh(Vm/60)); 
Cm = membrane leakage capacticance; 
Gm = membrane leakage conductance; 
Vm = membrane voltage; 
Vrest = membrane voltage @ neuron resting 
Gca = max Ca conductance through membrane 
Gk = max K conductance through membrane; 
mInf refers = P (Ca ion channel open) 
wInf refers = P (K ion channel open) 
Tau-w = rate which K channels respond to change in membrane voltage 
Eca = reversal potential of Ca 
Ek = reversal potential of K 
pulse(t) = stimulus applied to neuron 
pulse(t) = A (stim-on <= t <= stim-off) or 0 (else); 

的變量。

我創建了一個函數發送到ode45,如下所示。

function dy = ODEequation(t, Vm, w, constants, stim_on, stim_off, amp) 

wInf = (1 + tan(Vm/30))/2 
mInf = (1 + tan((Vm + 1)/ 15))/2 
tauW = 5/ (cosh(Vm/60)) 

pulse = amp * ((stim_on < t) - (t >= stim_off)); 

dy(1) = y(1) * ((-constants(2) - constants(4) * constants(9) - constants(5) * y(2)) + (constants(2) * constants(3) + constants(6) * constants(4) * constants(9) + constants(5) * y(2) * constants(7) + constants(11)))/constants(1) ; 
dy(2) = = (constants(8) - y(2))/constants(10) 
dy = dy' 

並且通過該函數是如下

function [t Vm] = ODEquestion(stim_on, stim_off, amp) 

%i) 
Cm = 1; 
Gm = 0.5; 
Vrest = -50; 
Gca = 1.1; 
Gk = 2; 
Eca = 100; 
Ek = -70; 

%ii) 
Vm(1) = -30; 
w(1) = 0.1; 

%iii) 
wInf = (1 + tan(Vm/30))/2 
mInf = (1 + tan((Vm + 1)/ 15))/2 
tauW = 5/ (cosh(Vm/60)) 


IC1 = Vm(1) % = -30 
IC2 = w(1) % = 0.1 

pulse = amp %* ((stim_on < t) - (t >= stim_off)); 

constants = [Cm , Gm, Vrest, Gca, Gk, Eca, Ek, wInf, mInf, tauW, pulse]; 

[t Vm]=ode45(@ODEequation,[-20 20],[-30, 0.1]',[],constants, stim_on, stim_off, amp); 
+0

可能的重複:http://stackoverflow.com/questions/2256229/matlab-how-do-i-pass-a-parameter-to-a-function –

回答

1

help ode45

ODE45解決非剛性微分方程,介質順序方法。

[TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates 
the system of differential equations y' = f(t,y) from time T0 to TFINAL 
with initial conditions Y0. ODEFUN is a function handle. For a scalar T 
and a vector Y, ODEFUN(T,Y) must return a column vector corresponding 
to f(t,y). 

因此函數ODEFUN預計只有兩個輸入(ty),而你的函數需要7個輸入。

可以通過以下對this site,或this question發現指令解決這個問題:

wrapper = @(t,Vm) ODEequation(t, Vm, w, constants, stim_on, stim_off, amp); 
[t Vm]=ode45(wrapper, [-20 20],[-30, 0.1]',[],constants, stim_on, stim_off, amp); 

例如,通過創建穿過所有的常數而轉發由ode45插入變量小包裝函數。