3D-Plot of a portfolio variance
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I would like to create a 3D-plot of the variance of a portfolio of two assets.
More precisely, let V denote the (2x2) variance covariance matrix and X denote the (2,1) vector of weights. The portfolio variance is then defined by the following matrix multiplication: X' * V * X
What I want to do is calculate the portfolio variance for all possible Xs, where the elements of X vary from -1 to +2 (-1:0.01:2).
I have already implemented a code:
a1 = [-1:0.01:2].';
a2 = [-1:0.01:2].';
b = zeros(length(a1),length(a1));
for i=1:length(a1);
for j=1:length(a1);
X=[a1(i,1); a2(j,1)];
b(j,i) = X.'*V*X;
end
end
This code runs, but it is computationally too expensive. Any ideas on how to implement this problem in a feasible way?
Thanks.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Portfolio Optimization and Asset Allocation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!