fmincon
is the right tool:
- Your unknown is a 2-element vector
[a; b]
- You need to supply a starting point guess
X0
for[a; b]
- Your cost function
FUN
is simply a function that returnsa+b
- You have two non-linear constraints and need to write a function for
NONLCON
Your NONLCON
function should:
- Accept the 2-element vector [a; b] as an input
- Evalute your model, TP1
- Return for
C
(first return value) a 2-element vector [x-x2; y-y2] - Return empty for the second return value
Ceq
You may also want to specify upper and lower bounds for your [a; b]
vector.