Why is ode45 not working when I insert the options input?
4 ビュー (過去 30 日間)
表示 古いコメント
I am trying to model some functions, but it seems that ode45 is not working. However, when I get rid of 'options' when I'm calling ode45, it runs but it will not finish running. I'm still new to MATLAB, so how can I fix this issue?
%CONSTANTS
i = 6.3;
a = 1;
b = 0.83;
vNa = 115;
vK = -12;
vL = 10.5989;
simtime = [0 100];
xinit = [0, 0.4, 0.1];
%CALLING FUNCTIONS
options=odeset('RelTol',1e-9,'Refine',10);
[t,x]=ode45(@(t,x) HHModel(t,i,a,b,vNa,vK,vL,x),simtime,xinit, options);
%GRAPHS
%Membrane Potential
subplot(221); plot(t,x(:,1)); grid on;
xlabel('Time [s]'); ylabel('v');
%FUNCTIONS
function amv = am(v)
amv = ((25-v)/10)/((exp((25-v)/10))-1);
end
function bmv = bm(v)
bmv = 4*exp(-v/18);
end
function tmv = tm(v)
tmv = 1/(am(v) + bm(v));
end
function anv = an(v)
anv = ((10-v)/100)/((exp((10-v)/10))-1);
end
function bnv = bn(v)
bnv = 0.125*exp(-v/80);
end
function dx = HHModel(t,i,a,b,vNa,vK,vL,x)
amv = am(x(1));
tmv = tm(x(1));
anv = an(x(1));
bnv = bn(x(1));
dx1 = i - 120*(x(3))^3*(b - a*(x(2)))*(x(1)-vNa) - 36*(x(2))^4*(x(1)-vK)-0.3*(x(1)-vL);
dx2 = anv - x(2)*(anv - bnv);
dx3 = amv - (x(3)/tmv);
dx = [dx1;dx2;dx3];
end
0 件のコメント
採用された回答
Jon
2022 年 6 月 29 日
Try ode15s instead, it seems to converge, you have to check if the answer makes sense
%CALLING FUNCTIONS
options=odeset('RelTol',1e-9,'Refine',10);
[t,x]=ode15s(@(t,x) HHModel(t,i,a,b,vNa,vK,vL,x),simtime,xinit,options);
その他の回答 (0 件)
参考
カテゴリ
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!