线性规划工具箱使用。
Show older comments
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'。
书上的代码粘过来的,直接运行不了,百度过只知道是工具箱的问题,但是不知道如何解决
Accepted Answer
More Answers (0)
Categories
Find more on 线性最小二乘 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!