Not directly, but one solution to this problem is to add a term to your equation that holds back your problem.
I don't have optimization tools, so I cannot give you a specific example using fsolve, but here is how I will do it with fminsearch, which has the same problem.
myFun = @(args) abs( sin(args(1)) + cos(args(2)) )
fminsearch(myFun, [0, 0])
ans =
-0.8520 0.7188
But if I want to limit my problem to positive solutions
myFun = @(args) abs(sin(args(1)) + cos(args(2))) + (args(1)<0) + (args(2)<0)
fminsearch(myFun, [0, 0])
ans =
0.0000 1.5708
There must be a way to tune your equation in a similar way to solve your problem.
source
share