Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Hello, I have that code and I really can't identify it's use. Can anyone correct that code and let me know what it's purpose? Thank yo
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function [ relMyScen ] = f_relativeMyScen( myScen)
% This function computes the 'relative' MyScen (from each asset, it subtracts the (peer/benchmark) portfolio return)
% myScen is a 3-D matrix (or tensor) of scenarios (NxTxK), N=number of assets, K = number of scenarios T = time period (scalar number of months)
% w_peer is Nx1 vector of portfolio weights where N=number of assets
s1 = size(myScen,1); % num of assets
s2 = size(myScen,2); % num of periods
s3 = size(myScen,3); % num of simulations
ret_peer = sum( repmat(w_peer(:), 1,s2, s3) .* myScen, 1 );
relMyScen = myScen + repmat(ret_peer, s2, 1, 1) ;
end
8 Kommentare
Image Analyst
am 27 Jul. 2014
That did not answer the question, so I'm going to assume it is homework and tag it as such. Good luck. If you do what I said in my answer then you'll see an error with a pretty obvious cause. If you fix that one, then there may or may not be another.
Antworten (1)
Image Analyst
am 27 Jul. 2014
Bearbeitet: Image Analyst
am 27 Jul. 2014
What if you just make up data? Like make up a 3D array and pass it in and see what errors you get:
function test3
clc;
a = rand(3,4,2);
relMyScen = f_relativeMyScen(a)
1 Kommentar
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!