%% Obtain Portfolios with Targeted Portfolio Risks for a Portfolio Object
% To obtain efficient portfolios that have targeted portfolio risks, the estimateFrontierByRisk function accepts one or more target portfolio risks and obtains efficient portfolios with the specified risks. Assume you have a universe of four assets where you want to obtain efficient portfolios with target portfolio risks of 12%, 14%, and 16%. This example uses the default 'direct' method to estimate the optimal portfolios with targeted portfolio risks.

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 = estimateFrontierByRisk(p, [0.12, 0.14, 0.16]);

 display(pwgt);

% Copyright 2015 The MathWorks, Inc.