Errors during solving equations - sym/subsindex (line 796) and sym/subsref (line 841)

10 views (last 30 days)
Hello, I need to solve the equations, in order to find Cadt and Cbdt. My code is:
syms Cadt Cat Cbdt Cbt dt Maa Mab Mbb k ga gb KA KB KC
eqn1 = (Cadt-Cat)/dt == Maa*(-k^2*ga - 2*(KA+KC)*k^4*Cadt - 2*KC*k^4*Cbdt) + Mab(-k^2*gb - 2*KC*k^4*Cadt - 2*(KB+KC)*k^4*Cbdt);
eqn2 = (Cbdt-Cbt)/dt == Mab*(-k^2*ga - 2*(KA+KC)*k^4*Cadt - 2*KC*k^4*Cbdt) + Mbb(-k^2*gb - 2*KC*k^4*Cadt - 2*(KB+KC)*k^4*Cbdt);
sol = solve([eqn1, eqn2], [Cadt, Cbdt]);
Sol1 = sol.Cadt
Sol2 = sol.Cbdt
However, I am getting theses errors:
Error using sym/subsindex (line 796)
Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When indexing, the
input must be numeric, logical, or ':'.
Error in sym/subsref (line 841)
R_tilde = builtin('subsref',L_tilde,Idx);
Error in Semi_implicit_conc_eqn_solve (line 8)
eqn1 = (Cadt-Cat)/dt == Maa*(-k^2*ga - 2*(KA+KC)*k^4*Cadt - 2*KC*k^4*Cbdt) + Mab(-k^2*gb - 2*KC*k^4*Cadt - 2*(KB+KC)*k^4*Cbdt);
It would be a great assistance if you let me know what went wrong in this code. Thanks a lot!

Accepted Answer

Walter Roberson
Walter Roberson on 11 Jun 2018
You forgot some multiplication operations when you defined formulas. MATLAB does not have any implied multiplication.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!