I'm trying to solve a system of differential eqs using ode45:
%My code is below
function xdot=fprime(t,x)
global I gCa gK gL VCa VK VL V1 V2 V3 V4 C
I=10^(-4); C=20*10^(-6);
gCa=4.4*10^(-6); gK=8.0*10^(-6); gL=2.0*10^(-6);
VCa=120*10^(-3); VK=-84*10^(-3); VL=-60*10^(-3);
V1=-1.2*10^(-3); V2=18*10^(-3); V3=2*10^(-3); V4=30*10^(-3);
minf=@(V) 0.5*(1+tanh((V-V1)/V2));
ninf=@(V) 0.5*(1+tanh((V-V3)/V3));
tau=@(V) 25/cosh((V-V3)/(2*V4));
timespan=[0 1]; xinit=[-0.08 0];
[t,y]= ode45(@fprime,timespan,xinit);
xdot=zeros(2,1);
xdot(1)=(gCa*minf(x(1))*(x(1)-VCa)+gK*x(2)*(x(1)-VK)+gL*(x(1)-VL))/C+I/C;
xdot(2)=(ninf(x(1))-x(2))/(tau(x(1)));
I use Matlab R2009A Portable.
one of the (few) solutions
- you could extend your recursion limit...
- better, though, reconsider your code...
nv=700;
set(0,'recursionlimit',nv);
us
Thank you, however, I tried 1000 as a recursion limit, and the same error. About second advice, how should I change the code? Somebody says to put ode in another m-file, but I dont feel it will work...
At a quick glance, and missing out the computations, it looks like this happens when you run your code:
something calls fprime
fprime calls ode45
ode45 calls fprime
fprime calls ode45
ode45 calls fprime
fprime calls ode45
ode45 calls fprime
fprime calls ode45
My recursion limit is 7 and now its been exceeded so I'll have to stop here - but hopefully the solution is now obvious.
*snip most of the "guts" of fprime*
> [t,y]= ode45(@fprime,timespan,xinit);
See Q4.15 in the newsgroup FAQ. Move this call to ODE45 OUT of fprime
itself.
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ