Thank u so much for your attention for my question, the minimum is the value required, the "fmincon" matlab function is used, and the algorithm is default, but there is a problem not addressed, the following is the code: After that, fmincon runs 2 times, the control value stays the same with the same matlab message. Can I limit this run's number? [X,FVAL] = fmincon(FUN,X0,...) returns the value of the objective function FUN at the solution X. [optm2, foptm2, exitflag] = fmincon(@(x) -eta2(x), x0, A, b, Aeq, beq, lb, ub, @(x)Constraints_2(x),options); f = @(x) (optm1 - eta1(x)).^2 + (optm2 - eta2(x)).^2 Look at that more carefully. See the documentation for a complete description. Static Memory Allocation for fmincon Code Generation. [X,FVAL,EXITFLAG] = fmincon(FUN,X0,...) returns an EXITFLAG that describes the exit condition. The curve of the f(x) is like the figure below (This is just 1 specific case as the coefficients of f(x) would vary from case to case but the form is the same) , and we can see the minimum point is around the labelled one at x=7.1e-12. Possible values of EXITFLAG and the corresponding exit conditions are listed below. Optimization options parameters used by fmincon.Some parameters apply to all algorithms, some are only relevant when using the large-scale algorithm, and others are only relevant when using the medium-scale algorithm.You can use optimset to set or change the values of these fields in the parameters structure, options.See Optimization Parameters, for detailed information. Output may not be optimal. The values it can take and what they indicate is described below: 0 : Optimal Solution Found; 1 : Maximum Number of Iterations Exceeded. fmincon stopped because the size of the current step is less than the selected value of the step size tolerance and constraints are satisfied to within the selected value of the constraint tolerance. Share. Most common are Exit Flags -2 and 2: ExitFlag = 2 Local minimum possible. The problem is a simple nonlinear minimization with both a nonlinear constraint function and linear constraints. All algorithms: I'm using the optimisation function "fmincon" and in some case it doesn't converge. Options. matlab optimization. Matlab link on Current Point and Function value mentions "The function value is the value of the objective function at the current point." [optm2, foptm2, exitflag] = fmincon(@(x) -eta2(x), x0, A, b, Aeq, beq, lb, ub, @(x)Constraints_2(x),options); f = @(x) (optm1 - eta1(x)).^2 + (optm2 - eta2(x)).^2 Look at that more carefully. for Branch and Bound solving), say to [0 5] x1 and [3 5] in x2, it doesn't work as intended, it still finds the solution within the original bounds. This example shows how to use static memory allocation in code generation even when some matrix sizes change during a computation. exitflag fsolve MATLAB. MATLAB: What does exitflag =2 mean for fsolve. I just completed and ran a fsolve loop that gave me some results with each iteration with exitflag=2. I have made a custom file for outputting fmincon solutions, the code below works for the supplied function and the bounds [0 5] in x1 and [0 5] in x2, but now if I want to go change bounds (eg. ExitFlag = -2 No feasible solution found. b) When the exitflag is -3, the objective function value returned by fmincon does NOT match the explicit calculation of function value at the x point returned by fmincon. Output may not be optimal. 2 : Maximum amount of CPU Time exceeded. Constraints satisfied. The exitflag allows the user to know the status of the optimization which is returned by Ipopt. Equation solved, fsolve stalled. Without code, it is hard to follow your specific problem, but the message (and probalb the exitflag) tells you that either your initial value or your objective-function sucks. 3 : Stop at Tiny Step.