% mat5

assets = ['DomBds'; 'DomStx'; 'ForStx'];
funds = ['FundA'; 'FundB'; 'FundC'];
A = [ .60 .20 0 ; .40 .50 .30; 0 .30 .70];

disp('A');
pmat(assets,funds,A,10,2);
disp(' ');

x =  [ .20; .30; .50];
b =  A*x;

disp('x');
pmat(' ' , funds,x,10,2);
disp(' ');

bb = [.15;.35;.50];
disp('bb');
pmat(' ' , assets,bb,10,2);
disp(' ');

xx =  inv(A)*bb;
disp('xx');
pmat(' ' , funds,xx,10,2);
disp(' ');

mixes = ['Mix1';'Mix2']
BBB = [ .15 .15 ; .35 .40; .50 .45];
disp('BBB');
pmat(mixes,assets,BBB,10,2);
disp(' ');

XXX = inv(A)*BBB;
disp('XXX');
pmat(mixes,funds,XXX,10,2);
disp(' ');

mixes3 = ['Mix1' ; 'Mix2'; 'Mix3'];
BBBB=  eye(3);
disp('BBBB');
pmat(mixes3,assets,BBBB,10,2);
disp(' ');

XXXX = inv(A)*BBBB;
disp('XXXX');
pmat(mixes3,funds,XXXX,10,2);
disp(' ');

disp('inv(A)');
pmat(mixes3,funds,inv(A),10,2);
disp(' ');

% expected returns on funds
erfunds = [ 7.50 9.65 10.85];
disp('erfunds');
pmat(funds,' ',erfunds,10,2);
disp(' ');

% question: what are the expected returns on the assets?
%        eassets  *       A        = erfunds
%      {1*assets) * {assets*funds} = {1*funds};
%   hence
%         eassets = erfunds   *   inv(A);
%      {1*assets}   {1*funds} *  {funds*assets}

erassets =  erfunds * inv(A); 
disp('erassets');
pmat(assets,' ',erassets,10,2);
disp(' ');