老师,请教您一个问题。(错误如图片所示)?
functionga_main19()clc,clearall,closeallfun=@fitnessfun;%设置适应度函数句柄,(在函数名前加@即可)nonlcon...
function ga_main19()clc,clear all,close allfun = @fitnessfun; % 设置适应度函数句柄,(在函数名前加@即可)nonlcon = @nonlconfun; % 设置非线性约束函数句柄% 已知量L5=80;H=1200;L4=sqrt(L5^2+H^2);Deb=atand(L5/H);Dec=90-Deb;Ded=90+Deb;nvars = 3; % 自变量个数A = []; b = []; % 线性不等式约束Aeq = []; beq = []; % 线性等式约束lb = [0;0;0]; ub = []; % 自变量定义域[L, fval,h] = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,[])endfunction f = fitnessfun(L)f = -acosd((L3^2+L4^2-(L1-L2)^2)./2*L3*L4);endfunction [c,ceq] = nonlconfun(L)%非线性不等式约束c(1,1) = ((L3-L2)^2+(L2+L3)^2-(2*L5)^2)./2*(L3-L2)*(L2+L3); c(2,1) = L1^2+L2^2-L3^2-L4^2;%非线性等式约束ceq (1,1)= 2*L1*L4*cosd(Ded)-L1^2-L4^2+(L2+L3)^2; ceq (2,1)= 2*L1*L4*cosd(Dec)-L1^2-L4^2+(L2-L3)^2;end
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询