how to obtain matrix with two symbolic equations with dsolve
3 次查看(过去 30 天)
显示 更早的评论
clc, clear
a1=28*7*400; %%ft^2
po=40.6; %%psi
dpio=9; %%psi
qf=1525; %%gpm
qo=qf;
pp=16.4; %%psi
qp=1234; %%gpm
depr1=24.9; %%psi
delp=depr1-pp; %%psi
delpr2=18.2; %%psi
PH=360; %%ft
lp=2.76*.264/(60)^2*14.5; %%gal/m*min^2/psi
k2=1.75*10^-4*60^1.67*14.5/264.172^1.67; %%psi/(gal/min)^1.67
k3=2.27*10^-2; %%(m^3/h)^.6/m^2
g=32.17; %%ft/s^2
rhoh20=62.4; %%lbs/ft^3
pf=rhoh20*g*PH*1.488*.000145; %%psi
dpo=pf-po; %%psi
eqns=ro_cp_model(lp,qo,dpio,k3,k2,dpo);
function dpq=ro_cp_model(lp,qo,dpio,k3,k2,dpo)
syms jjw dp(x) Q(x)
eqns=[diff(Q,x,1)==-(lp(dp-qo*dpio/Q*exp(jjw/(k3*Q^.4))))*am, diff(dp,x,1)==-k2*Q];
conditions=[dp(0)==dpo Q(0)==qo];
dpq=vpa(dsolve(eqns,conditions));
end
Error using symfun/subsindex (line 157)
Indexing values must be positive integers, logicals,
or symbolic variables.
Error in ro_cp_model (line 4)
eqns=[diff(Q,x,1)==-(lp(dp-qo*dpio/Q*exp(jjw/(k3*Q^.4))))*am,
diff(dp,x,1)==-k2*Q];
Error in mhlro (line 20)
eqns=ro_cp_model(lp,qo,dpio,k3,k2,dpo);
>>
I would like to show a matrix of the anwsers of the two diff. equations with the only uknown value beng jjw.
0 个评论
采纳的回答
Walter Roberson
2020-3-31
lp(dp-qo*dpio/Q*exp(jjw/(k3*Q^.4)))
You have requested variable lp indexed at expression dp-qo*dpio/Q*exp(jjw/(k3*Q^.4)) but that expression involves symbolic variables, and you can never index at a symbolic location.
MATLAB does not have implied multiplication in any context, not even inside the symbolic toolbox.
4 个评论
Walter Roberson
2020-3-31
I suggest you look at odeFunction() and in particular the first example which shows a good flow to work through to convert symbolic ODE into something to use numerically.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!