zhubo0709 发表于 2006-6-8 10:48

[求助]程序修改!关于微分方程组的! 高手来帮下(急)

[求助]程序修改!关于微分方程组的! 高手来帮下(急)

下面是程序:
function rgka4
y0=[-45,0.12,0.45];
tspan=;
N = length(tspan);
h = ones(1,N);
y0 = y0(:);
neq = length(y0);
Y = zeros(neq,N);
F = zeros(neq,4);
Y(:,1)=y0;
for i=2:N
ti=tspan(i-1);
hi=h(i-1);
yi=Y(:,i-1);
F(:,1)=feval(@odefun,ti,yi);
F(:,2)=feval(@odefun,ti+0.5*hi,yi+0.5*hi*F(:,1));
F(:,3)=feval(@odefun,ti+0.5*hi,yi+0.5*hi*F(:,2));
F(:,4)=feval(@odefun,ti,yi+hi*F(:,3)); %18行
Y(:,i)=yi + (hi/6)*(F(:,1) + 2*F(:,2) + 2*F(:,3) + F(:,4));
end
Y = Y.';
function f=odefun(t,s)

V=s(1);
n=s(2);
p=s(3);

am=0.1*(25 + V)/(1 - exp(-0.1*V - 2.5));
bm=4*exp(-(V + 50)/18);
ah=0.07*exp(-0.05*V - 2.5);
bh=1/(1 + exp(-0.1*V - 2));
an=0.01*(20 + V)/(1 - exp(-0.1*V - 2));
bn=0.125*exp(-(V + 30)/80);
gI=1800; gK=1700; gP=11.5;
gL=7; VI=100; VK= -75;
VL=-40; KC=0.18; tx_n=0.00435;
tp=5.0;
minf=am/(am + bm);hinf=ah/(ah + bh);
ninf=an/(an + bn);t_n=tx_n/(an + bn);

dVdt=gI*(minf^3)*(hinf)*(VI- V) + gK*(n^4)*(VK- V) + gP*p*(VK- V) + gL*(VL- V);
dndt=(ninf - n)/t_n; %43行
dpdt=(((minf^3)*(hinf)*(VI - V) - KC*p/(1-p))/tp)*((1-p).^2);

f = ';

错误信息在下边
请高手来诊断阿!到底是怎么回事啊?很急!

>> Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
> In C:\MATLAB6p5\work\rgka4.m (odefun) at line 43
In C:\MATLAB6p5\work\rgka4.m at line 18

[ 本帖最后由 lxq 于 2007-4-26 18:09 编辑 ]

笑石头 发表于 2006-6-9 17:23

<P>在这个程序的运行中<BR>出现分母为零的现象</P>

feifeifool 发表于 2006-6-9 17:29

<P>警告跟错误是不一样的!</P>
页: [1]
查看完整版本: [求助]程序修改!关于微分方程组的! 高手来帮下(急)