# How to use Solver?

9 ビュー (過去 30 日間)
Rebecca Reyes 2021 年 4 月 13 日

clear dlc
%feed composition
z1=.5;
z2=.1;
z3=.15;
z4=.25;
%other given data
F=150;
PD=250;
T=10;
F=150;
%k-values from chart yi/xi
k1=56;
k2=0.65;
k3=0.175;
k4=0.055;
%total balances
syms x
eqn=solve(k1*((F*z1)/(k1*x+150-x))+k2*((F*z2)/(k2*x+150-x))+k3*((F*z3)/(k3*x+150-x))+k4*((F*z4)/(k4*x+150-x))==1)
I'm trying to solve for x in the eqn but all i get is this:
eqn =
150
root(z^3 - (151985*z^2)/231 + (2120672000*z)/17787 - 36140000000/5929, z, 1)
root(z^3 - (151985*z^2)/231 + (2120672000*z)/17787 - 36140000000/5929, z, 2)
root(z^3 - (151985*z^2)/231 + (2120672000*z)/17787 - 36140000000/5929, z, 3)
Very confused since I had defined my z constants and I am only looking for the x variable

サインインしてコメントする。

### 採用された回答

madhan ravi 2021 年 4 月 13 日
Use vpasolve()
##### 6 件のコメント4 件の古いコメントを表示4 件の古いコメントを非表示
Rebecca Reyes 2021 年 4 月 13 日

I see what you are trying to tell me but i see that my approach is all wrong for what i need to get as an answer.
i redid my coding since my answer is supposed to be just one number 88.
I posted it on another post.
madhan ravi 2021 年 4 月 14 日

Wow , you just completely ignored what I told you and simply asked the same question.
%feed composition
z1=.5;
z2=.1;
z3=.15;
z4=.25;
%other given data
F=150;
PD=250;
T=10;
F=150;
%k-values from chart yi/xi
k1=56;
k2=0.65;
k3=0.175;
k4=0.055;
%total balances
syms x
Eqn = k1*((F*z1)/(k1*x+150-x))+k2*((F*z2)/(k2*x+150-x))+k3*((F*z3)/(k3*x+150-x))+k4*((F*z4)/(k4*x+150-x))==1;
X = vpasolve(Eqn) % you can see 4 answers so if you're looking for the root in a certain range say 50 - 100 you can use the below line
X =
X_in_the_range = vpasolve(Eqn, [50 100])
X_in_the_range =
88.652321154384366746951471346875
subs(Eqn, X_in_the_range) % to check if it satisfies, ofcourse it's not an exact solution but a close match to what you're looking for
ans =
Come on , was that hard for you ? The reason I suggested vpasolve() is that you can input the domain for the solver to look for. Please stop asking the same question multiple times just because you didn't understand. It's not encouraged in this forum. Volunteers spend some time in helping and instead of giving them a proper response OP's tend to ask another question simultaneously.

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by