Solving an equation gives me three possible answers. How can I reference only one of these answers?
1 view (last 30 days)
Show older comments
Christopher DSpain
on 22 Mar 2023
Answered: 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]=solve(eqnvel,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.
0 Comments
Accepted Answer
John D'Errico
on 22 Mar 2023
syms v f eta;
f=0.0394;
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]=solve(eqnvel,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.
fplot(v(3))
It appear that for negative eta, you get two positive real solutions.
vpa(subs(v,eta,-1))
vpa(subs(v,eta,1))
And for positive eta, there is one positive solution.
Can you "save" it? Sure. I might do this:
vfun = matlabFunction(v(3))
Now you can use that function for anything you please. Plot it, for example.
fplot(vfun,[0,5])
Evaluate it.
result = vfun(pi)
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!