%% Estimate Sharpe Ratios of the Given Portfolio Weights
% This example shows how to find efficient portfolios that satisfy the target returns and then find the Sharpe ratios corresponding to each of the portfolios.
% To obtain efficient portfolios that have targeted portfolio returns, the estimateFrontierByReturn function accepts one or more target portfolio returns and obtains efficient portfolios with the specified returns. Assume you have a  universe of four assets where you want to obtain efficient portfolios with target portfolio returns of 6%, 9%, and 12%. Use estimatePortSharpeRatio to obtain the Sharpe ratio for the collection of portfolios (pwgt).

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];
 
p = Portfolio;
p = setAssetMoments(p, m, C);
p = setDefaultConstraints(p);
pwgt = estimateFrontierByReturn(p, [0.06, 0.09, 0.12]);

display(pwgt);

% pwgt is a NumAssets-by-NumPorts matrix where NumAssets is the number of asset in the universe and NumPorts is the number of portfolios in the collection of portfolios.

psharpe = estimatePortSharpeRatio(p,pwgt) 

% psharpe is a NumPorts-by-1 vector, where NumPorts is the number of portfolios in the collection of portfolios.
% Copyright 2012 The MathWorks, Inc.