How can I solve this set of equations using the Symbolic Toolbox?
2 views (last 30 days)
Show older comments
Joris Bergman
on 28 Nov 2022
Commented: Joris Bergman
on 28 Nov 2022
Hi guys,
I am trying to solve a set of equations for a chemical equilibrium for the concentration of H2S using the symbolics toolbox and the solve function. I have the following code. In this system, the concentrations HS, H2S and S are unknown. The equilibrium constants K1 and K2 and the concentrations H2O, H and Stot are known as well.
syms HS H2S H K1 K2 Stot S H2O;
eqns=[K1==(HS*H)/(H2O*H2S),K2==(S*H)/(H2O*HS),Stot==S+HS+H2S];
solve(eqns,H2S);
To me, this is a system that contains three unknowns and three equations. However, when running this code, it fails to find a solution for H2S. What do I need to change to make this work?
Thanks in advance for any and all help!
0 Comments
Accepted Answer
Walter Roberson
on 28 Nov 2022
You need to solve for the same number of variables as you have equations.
More Answers (0)
See Also
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!