未定义与 'function_handle' 类型的输入参数相对应的运算符 '*'。
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
a=0.04;b=0.05;c=30;d=20;g=100;
f1=g*(@(x)exp(-b*x(2))/b+@(x)exp(-a*x(1))/a+((x(1)+x(2))-(b*x(2)+a*x(1)+1)/(a+b)-(a*b*(x(1)+x(2))-x(2)*a^2-x(1)*b^2)/((a+b)^2))*@(x)exp(-(b*x(2)+a*x(1))));
f2=c*(x(1)+(@(x)exp(-a*x(1))-1)/a+@(x)exp(-b*x(2))/b-(@(x)exp(-a*x(1))*@(x)exp(-b*x(2)))/(a+b));
f3=d*(x(2)+(@(x)exp(-b*x(2))-1)/b+@(x)exp(-a*x(1))/a-(@(x)exp(-a*x(1))*@(x)exp(-b*x(2)))/(a+b));
fun=f1+f2+f3;
lb=0;ub=80;
[x,fval]=ga(fun,2,[],[],[],[],lb,ub)
求大神帮忙看看,我想用ga工具箱求一个二元函数的最小值,运行完之后提示f1错误,原因是:未定义与 'function_handle' 类型的输入参数相对应的运算符 '*'。
0 Kommentare
Akzeptierte Antwort
fbpwacx
am 22 Mai 2023
仅供参考
a=0.04;b=0.05;c=30;d=20;g=100;
fun=@(x)g*(exp(-b*x(2))/b+exp(-a*x(1))/a+((x(1)+x(2))-(b*x(2)+a*x(1)+1)/(a+b)-(a*b*(x(1)+x(2))-x(2)*a^2-x(1)*b^2)/((a+b)^2))*exp(-(b*x(2)+a*x(1))))...
+c*(x(1)+(exp(-a*x(1))-1)/a+exp(-b*x(2))/b-(exp(-a*x(1))*exp(-b*x(2)))/(a+b))...
+d*(x(2)+(exp(-b*x(2))-1)/b+exp(-a*x(1))/a-(exp(-a*x(1))*exp(-b*x(2)))/(a+b));
lb=0;ub=80;
[x,fval]=ga(fun,2,[],[],[],[],lb,ub)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Energy Production finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!