Afficher commentaires plus anciens
clc, clear, c=[3, -1, -1];
a=[1, -2, 1; 4, -1, -2]; b=[11,-3]';
prob = optimproblem('ObjectiveSense','max');
x = optimvar('x',3,'LowerBound',0);
prob.Objective = c*x;
prob.Constraints.con1 = a*x<=b;
prob.Constraints.con2 = -2*x(1)+x(3)==1;
[sol, fval, flag, out] = solve(prob)
xx = sol.x %显示决策变量的值
未定义函数或变量 'optimproblem'。
书上的代码粘过来的,直接运行不了,百度过只知道是工具箱的问题,但是不知道如何解决
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 线性最小二乘 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!