selecting the positive result
9 views (last 30 days)
Show older comments
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 Comments
Image Analyst
on 23 Dec 2016
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.
Answers (1)
Aylin
on 27 Dec 2016
Edited: Aylin
on 27 Dec 2016
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
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!