Skip to Main Content Skip to Search
Product Documentation

addLinearConstraint - Add linear constraint to optimization

Syntax

options = addLinearConstraint(options, label, A, B)

Description

A method of cgoptimoptions. Adds a placeholder for a linear constraint to the optimization. The string label is used to refer to the constraint in the CAGE GUI. Linear constraints can be written in the form

A(1)X(1) + A(2)X(2) + ... + A(n)X(n) <= b 

where X(i) is the ith free variable, A is a vector of coefficients, and b is a scalar bound.

Examples

% Add SPK and EGR variables to an optimization
opt = addFreeVariable(opt, 'SPK');
opt = addFreeVariable(opt, 'EGR');
% Add a linear constraint such that 3*SPK - 2*EGR <= 30
opt = addLinearConstraint(opt, 'newCon', [3 -2], 30);

How To

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS