STILL confused on Solver (tried a different approach) NOT SPAM

please look over my new attempt
the answer for x is suppposed to be 88. I can't seem to get the answer
I am not trying to spam I just tried a new approach. Please Please help.
This is my approach.
clear dlc
%feed composition
z1=.5;
z2=.1;
z3=.15;
z4=.25;
%other given data
F=150;
PD=250;
T=10;
L=150-x;
F=150;
%k-values from chart yi/xi
k1=56;
k2=0.65;
k3=0.175;
k4=0.055;
%total balances
x1=(F*z1)/(k1*x+L);
x2=(F*z2)/(k2*x+L);
x3=(F*z3)/(k3*x+L);
x4=(F*z4)/(k4*x+L);
eqn=k1*x1+k2*x2+k3*x3+k4*x4==1;
sol=solve(eqn);
The only answer I get in command window this time is
>> Project (which is the name of the file)

4 Comments

Unrecognized function or variable 'x'.
Try removing the semicolon from the lines you want to see the output from (MATLAB Onramp Ch 2.1)
Do you happen to know how I can fix it to solve for x? I tried so many things...
You haven't declared what x is, so your code is returning an error. Did you mean to make it symbolic?
Yes, i think? x is what I'm hoping to solve for in the solver.

Sign in to comment.

 Accepted Answer

Assuming x is symbolic
%feed composition
z1=.5;
z2=.1;
z3=.15;
z4=.25;
%other given data
F=150;
PD=250;
T=10;
syms x
L=150-x;
%k-values from chart yi/xi
k1=56;
k2=0.65;
k3=0.175;
k4=0.055;
%total balances
x1=(F*z1)/(k1*x+L);
x2=(F*z2)/(k2*x+L);
x3=(F*z3)/(k3*x+L);
x4=(F*z4)/(k4*x+L);
eqn=k1*x1+k2*x2+k3*x3+k4*x4==1
eqn = 
sol=solve(eqn)
sol = 
double(sol)
ans = 4×1
150.0000 88.6523 173.8927 395.3987
It looks like there are 4 possible solutions to your equation, of which, a value close to 88 is one of them. If I solve your equation substituting in a value of 88, the result is close to 1.
double(subs(lhs(eqn),x,88))
ans = 1.0052

3 Comments

I see! your explanation really helped!
I just have one last question.
Is there a way to analyze those roots so that I can test them to see which root is closest to one or is the only way to input manually like how you did?
Your example,
double(subs(lhs(eqn),x,88))
double(subs(lhs(eqn),x,173)), etc...
If you use the exact values returned, every one of them will give you a result of 1. Otherwise, they wouldn't be a solution to the equation. It sounds like you need to maybe come up with a constraint for the solution, like it must be less than 100, for example.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!