selecting the positive result
9 次查看(过去 30 天)
显示 更早的评论
Hi everyone! I have a question on fsolve:i did a code for solving with fsolve 2eqs in 2 variables,but one of the variable is squared. What happens is that fsolve gives me the negative root of that variable,instead of the positive one. How can i achieve that? Maybe with some options? thanks.
2 个评论
Image Analyst
2016-12-23
So you're basically finding where a line intersects a parabola? Why doesn't it give all solutions? There should be two solutions unless your intersection point is perpendicular or tangent to the vertex of the parabola. Let's see your code - you forgot to include it.
回答(1 个)
Aylin
2016-12-27
编辑:Aylin
2016-12-27
Hello Domenico,
If you are trying to solve a polynomial equation, then you may want to use the roots function instead. However, if the fsolve function works best for you, please refer to the following MATLAB documentation page for some techniques on solving nonlinear systems with constraints:
In particular, if you would like to get only positive zeros from your code, you can run fsolve for a range of starting values, and then use only the starting values that give you positive results.
Rylan
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!