线性规划工具箱使用。

3 vues (au cours des 30 derniers jours)
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

开元遇到系统检测风控审核导致注单回传不给提现怎么办?【微81923899】
20版没问题,能得到结果
xx =
4.0000
1.0000
9.0000
你可能是没有安装对应的Optimization Toolbox优化工具箱导致缺失需要调用的函数。

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!