Help with solving two equations set equal to each other
7 views (last 30 days)
Show older comments
Hello,
I am having some trouble solving two separate equations for one variable between them. I thought I could input the two equations as a function separated by a semicolon and use fsolve to solve. The code so far is:
Na=6.022E23;
kb=1.381E-23;
Rg=Na*kb
Theta_E_alpha=160;
Fo_alpha=-38000;
Theta_E_beta=370;
Fo_beta=-61000;
x1=1; %Initial guess for solving (K)
fun1=@(T) [Fo_alpha+3*Rg*(T(1)*log(exp(Theta_E_alpha/T(1))-1));
Fo_beta+3*Rg*(T(1)*log(exp(Theta_E_beta/T(1))-1))];
X=fsolve(fun1,x1);
I want to solve for T common to both equations.
Can someone help, what am I missing? Thank you!
Mike
0 Comments
Accepted Answer
Shashank Prasanna
on 25 Jan 2013
Edited: Shashank Prasanna
on 25 Jan 2013
Your current setup is forcing both the equations to zero individually. However if you intention is to solve for T such that equation_1 = equation_2 Then you can just subtract one from the other and call fsolve.
fun1=@(T) [Fo_alpha+3*Rg*(T(1)*log(exp(Theta_E_alpha/T(1))-1)) - Fo_beta-3*Rg*(T(1)*log(exp(Theta_E_beta/T(1))-1))]
X=fsolve(fun1,x1);
More Answers (1)
Roger Stafford
on 25 Jan 2013
It is important to realize that ordinarily one cannot solve two simultaneous equations with only one unknown. It generally takes as many unknowns as equations. It is very likely that will be true in this case.
Think of it this way. Solving a single equation for an unknown amounts to finding the point on an x-axis where some function of x crosses that x-axis. How likely is it that two different functions will cross the x-axis at exactly the same point? There would have to be something very special about the functions for that to be true.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!