solve 4 equations with some unknowns parameters.
이전 댓글 표시
I'm attempting to solve this problem which is attached. But I faced ERROR. Any suggestions?

댓글 수: 12
Matt J
2018년 11월 2일
This looks like only part of the message. The full error message should give a reason, as well as the error location.
madhan ravi
2018년 11월 2일
편집: madhan ravi
2018년 11월 2일
when I ran your code it didn't have any errors instead it returned all zeros
Skill_s
2018년 11월 2일
Skill_s
2018년 11월 2일
madhan ravi
2018년 11월 2일
do you have symbolic toolbox? type ver in command window to check whether you have that toolbox
Skill_s
2018년 11월 2일
Star Strider
2018년 11월 2일
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
2018년 11월 2일
채택된 답변
추가 답변 (1개)
Florian Augustin
2018년 11월 2일
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
Skill_s
2018년 11월 2일
Matt J
2018년 11월 2일
@Skill93,
If Florian's answer was what you were looking for, then you should Accept-click it.
Walter Roberson
2018년 11월 2일
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
2018년 11월 2일
Stephan
2018년 11월 2일
Executing your code in 2018b gives the same result. So you need a better approach.
Walter Roberson
2018년 11월 2일
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
2018년 11월 3일
카테고리
도움말 센터 및 File Exchange에서 Unit Conversions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!