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 日間)
Antonis
Antonis 2014 年 7 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Antonis
Antonis 2014 年 7 月 27 日
This is one of the tasks that I have to do. But I really can not understand anything about that code and what their orders doing. That's why I have asked that question here that I know there are probably more experienced people in this forum than me.
Image Analyst
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
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)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by