F = 0;%目标函数
Constraints = [];%约束条件
添加约束条件如下:
Constraints = [Constraints,0<=P1(1)<=2];
生成目标函数如下:
F = F + P1(1);
调用求解器如下:
options = sdpsettings('solver','cplex');
sol = optimize(Constraints,F,options);
输出F:
disp(value(F));
具体的可以看下我的博客或者看Yalmip网站:https://yalmip.github.io/command/optimize/