optimization function in matlab
1 次查看(过去 30 天)
显示 更早的评论
i would like to ask about the optimization in matlab function that works with multi variable input with each input has different boundaries the output is only one variables
0 个评论
采纳的回答
John D'Errico
2015-11-29
help fmincon
Or, as found on the file exchange, fminsearchbnd.
5 个评论
John D'Errico
2015-11-30
Read the help for fmincon.
You cannot simply pass in a list of variables in any order as arguments and expect fmincon to know that the 3rd and 4th arguments are to be interpreted as bounds.
READ THE HELP!!!!!
[x,fval,exitflag,output] = fmincon(fun,x0,[],[],[],[],Lb,Ub);
As you were passing in those arguments, fmincon thought they were to be treated as the equations for a set of linear INEQUALITY constraints. As such, what it thought were A and b were inconsistent in size.
更多回答(1 个)
Torsten
2015-11-30
fun = @(x)(x(1)-5)^2+(x(2)+6)^2+x(3);
x0 = [1 1 1];
Lb=[0 -1 2];
Ub=[1 2 3];
[x,fval,exitflag,output] = fmincon(fun,x0,[],[],[],[],Lb,Ub);
disp(fval)
Best wishes
Torsten.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!