Accelerating the pace of engineering and science

# setEquality

Class: PortfolioCVaR

Set up linear equality constraints for portfolio weights in PortfolioCVaR object

## Syntax

obj = setEquality(obj,AEquality,bEquality)

## Description

obj = setEquality(obj,AEquality,bEquality) sets up linear equality constraints for portfolio weights.

Given linear equality constraint matrix AEquality and vector bEquality, every weight in a portfolio Port must satisfy the following:

` AEquality * Port = bEquality`

## Tips

• You can also use dot notation to set up linear equality constraints for portfolio weights.

`obj = obj.setEquality(AEquality, bEquality);`
• Linear equality constraints can be removed from a PortfolioCVaR object by entering [] for each property you want to remove.

## Input Arguments

 obj CVaR portfolio object [PortfolioCVaR]. AEquality Matrix to form linear equality constraints [matrix]. bEquality Vector to form linear equality constraints [vector].
 Note:   An error results if AEquality is empty and bEquality is nonempty or if AEquality is nonempty and bEquality is empty.

## Output Arguments

 obj Updated CVaR portfolio object [PortfolioCVaR].

## Attributes

 Access public Static false Hidden false

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

## Examples

expand all

### Set Linear Equality Constraints

Suppose you have a portfolio of five assets and you want to ensure that the first three assets are 50% of your portfolio. Given a PortfolioCVaR object p, set the linear equality constraints and obtain the values for AEquality and bEquality:

```A = [ 1 1 1 0 0 ];
b = 0.5;
p = PortfolioCVaR;
p = setEquality(p, A, b);
disp(p.NumAssets);
disp(p.AEquality);
disp(p.bEquality);
```
```     5

1     1     1     0     0

0.5000

```