Please help me to solve the errors in the program

9 views (last 30 days)
clc
IntCon = 1;
function z=fun(x)
z = ((x(1)^2 + x(2)^2 - 11)^2 + (x(1)+ x(2)^2 - 7)^2 );
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0];
ub = [6 6];
nonlcon = [];
x = ga(@fun,2,A,b,Aeq,beq,lb,ub,nonlcon,IntCon)

Answers (1)

Walter Roberson
Walter Roberson on 9 May 2021
Just need the definition for the function to be below the rest of the script.
IntCon = 1;
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0];
ub = [6 6];
nonlcon = [];
x = ga(@fun,2,A,b,Aeq,beq,lb,ub,nonlcon,IntCon)
Optimization terminated: average change in the penalty fitness value less than options.FunctionTolerance and constraint violation is less than options.ConstraintTolerance.
x = 1×2
3.0000 1.7321
function z=fun(x)
z = ((x(1)^2 + x(2)^2 - 11)^2 + (x(1)+ x(2)^2 - 7)^2 );
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!