Restrain fsolve and fzero to return only postivie solutions
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to solve some non linear equations, quite simply I would say, with fzero and fsolve. I get a solution but I would like to aquire only positve solutions, which they do exist. Is there a way to avoid negative solutions ?
I would like to note that I have tried fzero(fun,[xlower, xupper]) but unfortunately it doesn't work.
0 comentarios
Respuestas (1)
Torsten
el 17 de Feb. de 2022
In fzero or fsolve, square the x vector with which you are asked to evaluate your equation:
function res = fun(x)
x = x.^2;
...
res = ...
end
Then, when fzero or fsolve returns to the calling program, x.^2 solves your equations, and x.^2 is non-negative.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!