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 个评论
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