Why won't this ODE setup work?
3 views (last 30 days)
Show older comments
I'm trying to solve a system of differential equations with initial conditions in order to run simulations over time. Here is my code.
k1=23.18*10^3;
k2=192.7;
k_1=357.4;
k_2=.03;
syms cs(t) ces(t) cp(t) ce(t)%solving diff eq
eqs=diff(cs) == (-k1*ce*cs)+(k_1*ces);
eqces=diff(ces) == ((-k_1-k2)*ces)+(k1*ce*cs)+(k_2*ce*cp);
eqcp=diff(cp) == (-k_2*ce*cp)+(k2*ce*cp);
eqce=diff(ce) == (-k1*ce*cs)-(k_2*ce*cp)+((k_1+k2)*ces);
odes=[eqce; eqs; eqces; eqcp]
cond1 = ce(0) == (5*10^(-8));
cond2 = cs(0) == .004;
cond3= ces(0) == 0;
cond4= cp(0) == 0;
conds=[cond1; cond2; cond3; cond4];
[ceSol(t), csSol(t), cesSol(t), cpSol(t)]= dsolve(odes,conds);%I get an error on this line that says invalid indexing or function definition
ceSol(t)= simplify(ceSol(t));
csSol(t)= simplify (csSol(t));
cesSol(t)= simplify (cesSol(t));
cpSol(t)= simplify (cpSol(t));
Any idea where I'm going wrong?
0 Comments
Answers (1)
Jan
on 9 Feb 2022
Omit the "(t)" in the output:
[ceSol, csSol, cesSol, cpSol]= dsolve(odes,conds);
2 Comments
Jan
on 9 Feb 2022
When I run the code, I get the warning: "Unable to find symbolic solution". Most ODEs do not have a symbolic solution, but you have to solve them numerically. Do you have any reason to assume, that there is a symbolic solution of your equation?
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!