matlab等式操作,等式和等式约束

x = optimvar('x',4,6);

constrsum = sum(x,2) == 1

constrsum =

4x1 Linear OptimizationEquality array with properties:

IndexNames: {{} {}}

Variables: [1x1 struct] containing 1 OptimizationVariable

See equality formulation with show.

show(constrsum)

(1, 1)

x(1, 1) + x(1, 2) + x(1, 3) + x(1, 4) + x(1, 5) + x(1, 6) == 1

(2, 1)

x(2, 1) + x(2, 2) + x(2, 3) + x(2, 4) + x(2, 5) + x(2, 6) == 1

(3, 1)

x(3, 1) + x(3, 2) + x(3, 3) + x(3, 4) + x(3, 5) + x(3, 6) == 1

(4, 1)

x(4, 1) + x(4, 2) + x(4, 3) + x(4, 4) + x(4, 5) + x(4, 6) == 1

prob = optimproblem;

prob.Constraints.constrsum = constrsum

prob =

OptimizationProblem with properties:

Description: ''

ObjectiveSense: 'minimize'

Variables: [1x1 struct] containing 1 OptimizationVariable

Objective: [0x0 OptimizationExpression]

Constraints: [1x1 struct] containing 1 OptimizationConstraint

See problem formulation with show.

eqnprob = eqnproblem;

eqnprob.Equations.constrsum = constrsum

eqnprob =

EquationProblem with properties:

Description: ''

Variables: [1x1 struct] containing 1 OptimizationVariable

Equations: [1x1 struct] containing 1 OptimizationEquality

See problem formulation with show.

12-08

05-03 1万+
11-03 1万+
12-28 2万+
04-13 400

“相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

©️2022 CSDN 皮肤主题：1024 设计师：我叫白小胖

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。