Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
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 (최근 30일)
이전 댓글 표시
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
Image Analyst
2014년 7월 27일
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.
답변 (1개)
Image Analyst
2014년 7월 27일
편집: Image Analyst
2014년 7월 27일
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
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!