Solving an equation gives me three possible answers. How can I reference only one of these answers?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
John D'Errico
2023-3-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!