Help me with my function

function [E_Rp, sigma_Rp] = portfolioReturn( weight, expRets, vols, corr)
% compute the expected return and volatility of a portfolio of two assets
%%input parameters
% weight - weight of Asset 1
% expRets - 2x1 vector of expected returns of the two assets
% vols - 2x1 vector of vector of volatilities of the two assets
% corr - correlation between the two assets
%%output parameters
% E_Rp - expected return of the portfolio
% sigma_Rp - volatility of the portfolio
E_Rp = [weight,(1-weight)] * expRets';
Variance_of_two = [weight^2,(1-weight)^2]* vols'+ 2* weight*(1-weight)*corr ;
sigma_Rp = sqrt(Variance_of_two);
end
I wrote this function to compute expected return and volatility of a portfolio
It should work as follows , but why it does not work in the fuctioin with same script
expRets = [0.136,0.150];
weight = 0.4;
E_Rp = [weight,(1-weight)] * expRets'

2 件のコメント

Star Strider
Star Strider 2019 年 11 月 6 日
How are you calling portfolioReturn?
Hari Krishna Ravuri
Hari Krishna Ravuri 2019 年 11 月 8 日
The function looks fine. Provide some more information regarding the usage of the function.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePortfolio Optimization and Asset Allocation についてさらに検索

質問済み:

2019 年 11 月 5 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by