Solving an ODE numerically .. What is the problem in my code?

조회 수: 2 (최근 30일)
Esraa Abdelkhaleq
Esraa Abdelkhaleq 2016년 8월 21일
댓글: Torsten 2016년 8월 22일
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
John D'Errico
John D'Errico 2016년 8월 21일
Why do you think there is a problem? Did an error occur?
Esraa Abdelkhaleq
Esraa Abdelkhaleq 2016년 8월 22일
편집: Esraa Abdelkhaleq 2016년 8월 22일
yes, the error appears as:
Error: Unexpected MATLAB expression.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2016년 8월 22일
Use fplh_Rh_Nh instead of fplh*Rh*Nh:
fplh_Rh_Nh = 4.56e3;
...
dqpldt=fplc*Rc*Nc0*exp(Kgr*t)+fplh_Rh_Nh0-Kel*qpl
Best wishes
Torsten.
  댓글 수: 2
Esraa Abdelkhaleq
Esraa Abdelkhaleq 2016년 8월 22일
편집: Esraa Abdelkhaleq 2016년 8월 22일
Dear Torsten,
Thanks a lot.
I did what you said but the same error appeared !
May I have a problem in the version itself? how can I check that everything is OK in the version? I use 2008a version.
Torsten
Torsten 2016년 8월 22일
Use
dqpldt=fplc*Rc*Nc0*exp(Kgr*t)+fplh_Rh_Nh-Kel*qpl
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by