how to obtain matrix with two symbolic equations with dsolve

3 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 31 Mar 2020
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 Comments
Walter Roberson
Walter Roberson on 31 Mar 2020
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!