How to pick an answer from solver for further calculations

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

Antworten (1)

darova
darova am 30 Mär. 2020
Use logical operators
ix = 0<Xi && Xi<1;
x1 = Xi(ix);

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 30 Mär. 2020

Kommentiert:

am 30 Mär. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by