Solving an equation gives me three possible answers. How can I reference only one of these answers?

1 view (last 30 days)
syms v f eta;
f = 0.0394
eqnvel = (9.801-3.802*v)*v*eta==(((f*200*(pi/4)*0.1^2)/6.434)+((27*(pi/4)*0.1^2)/64.34))*v^3;
v = 
I have three possible answers as a result of this solve. Is there a way for me to save the positive answer as a variable so I can use it in a different equation? V will change as eta changes and I would like to graph it from eta= 0.6 to eta=0.9. Any help with this would be greatly appreciated.

Accepted Answer

John D'Errico
John D'Errico on 22 Mar 2023
syms v f eta;
f = 0.0394;
eqnvel = (9.801-3.802*v)*v*eta==(((f*200*(pi/4)*0.1^2)/6.434)+((27*(pi/4)*0.1^2)/64.34))*v^3;
v = 
There is no positive answer, since the non-zero roots are a function of eta, and depending on the value of eta, we might see positive or negative solutions.
It appear that for negative eta, you get two positive real solutions.
ans = 
ans = 
And for positive eta, there is one positive solution.
Can you "save" it? Sure. I might do this:
vfun = matlabFunction(v(3))
vfun = function_handle with value:
Now you can use that function for anything you please. Plot it, for example.
Evaluate it.
result = vfun(pi)
result = 2.5707

More Answers (0)

Community Treasure Hunt

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

Start Hunting!