%% Add a Linear Equality Constraint for a Portfolio Object
% Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = Portfolio;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;
p = addEquality(p, A, b);

disp(p.NumAssets);
disp(p.AEquality);
disp(p.bEquality);

% Copyright 2015 The MathWorks, Inc.