Solving an ODE numerically .. What is the problem in my code?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to solve this ODE numerically..
dq_pl/dt=f_plc*R_c*N_c0*exp(K_gr*t)+f_plh*R_h*N_h0-K_el*q_pl(t).
Where the letters following the underscore signs are subscripts, the parameters values are:
fplc=0.1 ; Rc=4.5*10^-5 ; Nc0=1 ; Kgr= 5.78*10^-3 ; fplh*Rh*Nh=4.56*10^3 ; Kel= 0.11 ;
tspan = [0 10^10] , qpl0 = 0
I wrote:
function [t,qpl] = call_dstate()
tspan = [0 10^10]; % set time interval
qpl0 = 0; % set initial condition
% dstate evaluates r.h.s. of the ode
[t,qpl] = ode45( @dstate ,tspan ,qpl0);
plot(t,qpl)
disp([t,qpl]) % displays t and qpl(t)
function dqpldt = dstate (t,qpl)
fplc=0.1 ; Rc=4.5*10^-5 ; Nc0=1 ; Kgr= 5.78*10^-3 ; fplh*Rh*Nh=4.56*10^3 ; Kel= 0.11 ;
dqpldt=fplc*Rc*Nc0*exp(Kgr*t)+fplh*Rh*Nh0-Kel*qpl;
end
end
Thanks in advance.
2 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!