Problem with ordinary differental equation

Good Afternoon,
I have a problem on how to solve differential equation which is dsdx and dxdPO2_rbc. This is the equation that I want to solve:
dPO2dt= (Qb*(O2_bloodin - O2_blood)+ (DO2_m * (PO2_g - PO2,b)))./ (Vb * (alpha_O2 + (cap_b * dsdx * dxdp))); %.... equation (1)
which:
a1= -8532;
a2= 2121;
a3= -67.07;
a4= 936000;
a5= -31350;
a6= 2396;
a7= -67.10;
T= 37;
r= 0.69;
H_rbc= 61*exp(-9);
ph_virt= -log(r*H_rbc);
PO2_rbc= 90 %mmHg;
pco2= 46 %mmhg;
I have problem with dsdx and dxdPO2, where
S(x)=(a1*x + a2*x^2 + a3*x^3 + x^4)/ (a4 + a5*x + a6*x^2 + a7*x^3 + x^4) %.......(equation 2)
x= PO2_rbc * (10^(0.024*(37-T) + 0.4*(ph_virt - 7.4)+ 0.06*(log(40/PCO2)))) %.........(equation 3)
I try to differentiate S with respect to x using 'diff', and differentiate x with respect to PO2_rbc, but the result is in symbolic (sym) form. Hence, it cannot be solved in equation (1).
Could somebody help me with this problem? I mean, should I use 'diff' to solve dSdx and dxdPO2_rbc, or another method?
Thanks..

 채택된 답변

Karan Gill
Karan Gill 2016년 12월 1일
편집: Karan Gill 2017년 10월 17일

0 개 추천

I think what you're asking is how to go from symbolic to numeric form? Use the "subs" function to substitute symbolic values with numbers. Then convert the symbolic result to double using "double".

댓글 수: 3

fiza fiza
fiza fiza 2016년 12월 5일
Thank you very much Karan Gill for your help. I really appreciate it. I tried the suggested step using the matlab code below:
%%%%%%%
syms a1 a2 a3 a4 a5 a6 a7 T x S(x);
dsdx= dsolve (diff(S,x))== ((a1*x) + (a2*(x^2)) + (a3*(x^3)) + (x^4))/ (a4 + a5*x + (a6*(x^2)) + (a7*(x^3)) + (x^4));
x= Xa(9) * (10^(0.024*(37-T) + 0.4*(ph_virt - 7.4)+ 0.06*(log(40/Xa(3)))));
a1= -8532; a2= 2121; a3= -67.07; a4= 936000; a5= -31350; a6= 2396; a7= -67.10; T= 30;
dsdx;
subs(dsdx);
doubledsdx= double(dsdx);
%%%%%%%
Then I used doubledsdx in the next equation:
%%%%%%%
dPO2dt= (Qb*(O2_bloodin - O2_blood)+ (DO2_m * (PO2_g - Xa(9))))./ (Vb * (alpha_O2 + (cap_b * doubledsdx * doubledxdp)));
%%%%%%%
unfortunately, when I tried to solve dPO2dt using ode45, my matlab cannot solve it (command window became continuously 'busy' until I hit ctr+C). The same situation occur when I use ode15s and ode23.
I don't know what is wrong with my coding, but I desperately need to do this simulation. May I get your comment on this problem?
Thank you..
Karan Gill
Karan Gill 2016년 12월 8일
If you used "dsolve" so solve your problem symbolically, then why are you giving the solution from "dsolve" to "ode45". You already have the solution in double form. Just try to plot it using "plot" etc.
fiza fiza
fiza fiza 2017년 1월 9일
편집: fiza fiza 2017년 1월 9일
OK.. I changed to this code, and it works. Thanks... :-)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
syms x
S= ((a1*x) + (a2*(x^2)) + (a3*(x^3)) + (x^4))/ (a4 + a5*x + (a6*(x^2)) + (a7*(x^3)) + (x^4));
diff_S= jacobian(S,x);
diff_simple= simplify(diff_S);
eqn= Xa(8) * (10^(0.024*(37-T) + 0.4*(ph_virt - 7.4)+ 0.06*(log(40/Xa(3)))));
int_subs= subs(diff_simple,x,eqn);
h= double(int_subs);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2016년 12월 1일

답변:

2023년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by