Accelerating the pace of engineering and science

# getGroupRatio

Class: Portfolio

Obtain group ratio constraint arrays from Portfolio object

## Syntax

[GroupA,GroupB,LowerRatio,UpperRatio] = getGroupRatio(obj)

## Description

[GroupA,GroupB,LowerRatio,UpperRatio] = getGroupRatio(obj) obtains the group ratio constraint arrays from a Portfolio object.

## Tips

You can also use dot notation to obtain the equality constraint arrays from the Portfolio object.

`[GroupA, GroupB, LowerRatio, UpperRatio] = obj.getGroupRatio;`

## Input Arguments

 obj Portfolio object [Portfolio].

## Output Arguments

 GroupA Matrix that forms base groups for comparison [matrix]. GroupB Matrix that forms comparison groups [matrix]. LowerRatio Lower bound for ratio of GroupB groups to GroupA groups [vector]. UpperRatio Upper bound for ratio of GroupB groups to GroupA groups [vector].

## 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

### Obtain Group Ratio Constraints

Suppose you want to make sure that the ratio of financial to nonfinancial companies in your portfolios never goes above 50%. Assume you have 6 assets with 3 financial companies (assets 1-3) and 3 nonfinancial companies (assets 4-6). After setting group ratio constraints, obtain the values for GroupA, GroupB, LowerRatio, and UpperRatio.

```GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = Portfolio;
p = setGroupRatio(p, GA, GB, [], 0.5);
[GroupA, GroupB, LowerRatio, UpperRatio] = getGroupRatio(p)
```
```GroupA =

1     1     1     0     0     0

GroupB =

0     0     0     1     1     1

LowerRatio =

[]

UpperRatio =

0.5000

```