solve 4 equations with some unknowns parameters.
Show older comments
I'm attempting to solve this problem which is attached. But I faced ERROR. Any suggestions?

12 Comments
Matt J
on 2 Nov 2018
This looks like only part of the message. The full error message should give a reason, as well as the error location.
madhan ravi
on 2 Nov 2018
Edited: madhan ravi
on 2 Nov 2018
when I ran your code it didn't have any errors instead it returned all zeros
Skill_s
on 2 Nov 2018
Skill_s
on 2 Nov 2018
madhan ravi
on 2 Nov 2018
do you have symbolic toolbox? type ver in command window to check whether you have that toolbox
Skill_s
on 2 Nov 2018
Star Strider
on 2 Nov 2018
The ver output disagrees with you:
MATLAB Version 7.11.0.584 (R2010b)
Operating System: Microsoft Windows 7 Version 6.2 (Build 9200)
...
Symbolic Math Toolbox Version 5.5 (R2010b)
...
Skill_s
on 2 Nov 2018
Accepted Answer
More Answers (1)
Florian Augustin
on 2 Nov 2018
Hi,
I think you are using a modern syntax to call 'solve' that was not supported in R2010b. The equivalent call in R2010b would be
syms a A B C D eps1 eps2 eps3 k1 k2 k3;
eqn1 = (C*exp(k1*a))+(D*exp(-k1*a))-(A*exp(-k3*a));
eqn2 = ((-(C*k1)/eps1)*exp(k1*a))+(((D*k1)/eps1)*exp(-k1*a))-(((A*k3)/eps3)*exp(-k3*a));
eqn3 = (C*exp(-k1*a))+(D*exp(k1*a))-(B*exp(-k2*a));
eqn4 = ((-(C*k1)/eps1)*exp(-k1*a))+(((D*k1)/eps1)*exp(k1*a))+(((B*k2)/eps2)*exp(-k2*a));
sol = solve(eqn1, eqn2, eqn3, eqn4, A, B, C, D);
ASol = sol.A
BSol = sol.B
CSol = sol.C
DSol = sol.D
You can access the documentation for your release of MATLAB by typing 'doc solve' in the MATLAB interface.
Hope this helps,
-Florian
7 Comments
Skill_s
on 2 Nov 2018
Matt J
on 2 Nov 2018
@Skill93,
If Florian's answer was what you were looking for, then you should Accept-click it.
Walter Roberson
on 2 Nov 2018
If I recall correctly, in R2010b, the syntax used for solve() was available but not clearly documented.
The problem was elsewhere: before R2011b, using relational expressions with symbolic expressions caused the expressions to be evaluated as a logical immediately. So the line
eqn1 = (C*exp(k1*a))+(D*exp(-k1*a))-(A*exp(-k3*a))==0;
built the expression on the left side, and immediately compared it to 0, found it was not identical, and immediately returned false into eqn1.
The workaround in those days was to not do the ==0 part on the equations: convert
eqn = A == B
to
eqn = (A) - (B)
And in those days, if you had an inequality such as
eqn1 = (C*exp(k1*a))+(D*exp(-k1*a))-(A*exp(-k3*a)) > 3
then you would have to build it using character vectors,
eqn1 = '(C*exp(k1*a))+(D*exp(-k1*a))-(A*exp(-k3*a)) > 3'
This would pretty much force you to use separate entries in the solve() command, like the
sol = solve(eqn1, eqn2, eqn3, eqn4, A, B, C, D);
that Florian shows, since [eqn1, eqn2, eqn3, eqn4] with character vectors would result in a single long character vector instead of multiple equations.
So, Florian's suggested code should work for the purpose, just not for exactly the reason that Florian indicated.
Skill_s
on 2 Nov 2018
Stephan
on 2 Nov 2018
Executing your code in 2018b gives the same result. So you need a better approach.
Walter Roberson
on 2 Nov 2018
MATLAB gives all 0.
If you work through the equations one by one doing stepwise elimination, then all 0 is the only solution.
Skill_s
on 3 Nov 2018
Categories
Find more on Unit Conversions 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!