MATLAB: Fmincon and constraints inherant to the function

constraintsfmincon

Good evening,
I am currently stuck on a problem and till now couldn't find a solution to it.
I'm using fmincon to find the minimum of a cost function forecastSOC, with variables x(1) and x(2):
[z1,z2,z3,z4] = fmincon(@(x)forecastSOC(x,aConst),x,A,b,Aeq,beq,lb,ub);
Now, what I would like to do is add a constraint to a variable y (vector) that is calculated in my function (y depends x(1) and x(2)). For example let's say the values of y should always stay between 60 and 90.
I've tried to included y(x(1),x(2)) as a decision parameter, then add upper and lower boundaries; I also tried non linear constraints.. with no success.
I hope very much that you can help me. Thank you
kind regards

Best Answer

I also tried non linear constraints
If y is a nonlinear (and twice differentiable) function of x, there's no obvious reason this wouldn't have worked.