How can I declare a nonlinear constraint in MATLAB as a开发者_如何学运维n anonymous function. I don't have any inequality constrained, only one equality.
What you need to do is to create an anonymous functions that outputs two arguments. You can do that as follows:
@(x) deal(x^2, 0 )
is what you want. The inequality constraint is the first argument. If you want to have both then equality and inequality constraints it is just.
@(x) deal(x^2, x+1)
精彩评论