How to pick an answer from solver for further calculations

1 vue (au cours des 30 derniers jours)
Hazal
Hazal le 30 Mar 2020
Commenté : Hazal le 30 Mar 2020
Hi there!
I would be appreciated if someone could help me about following codes.
syms Xi
%Feed Stoichiometry
yCO = 0.15;
yCO2 = 0.1;
yH2 = 0.45;
yH2O = 0.30;
%Equilibrium
eqn = ((yCO2 + Xi) * (yH2 + Xi) / (yCO - Xi) * (yH2O - Xi));
S = solve(eqn - K == 0, Xi)
Xi = vpa(S)
Here, I get 3 different answers and I would like to pick the one between 0 and 1 (for any value of K) to do further calculations. For K = 1.3440e+04, answer values are below.
Xi =
0.1499983259199154580821882262029
115.73248002820162922028599235038
-116.13247835412154467836818057659

Réponses (1)

darova
darova le 30 Mar 2020
Use logical operators
ix = 0<Xi && Xi<1;
x1 = Xi(ix);

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by