i have a problem with my code and i dont know how solve this?
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix of monthly returns I call Ynet (193.1) I'd like to build a matrix yields random I call randomR with an average yield of my one line is equal to the value of the row Ynet has.
Ynet example, if (1,1) = 0.23 I need the average randomR (1, :) is equal to 0.23.
Until then I got there, the problem comes from my values of my matrix randomR I need them to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30 depending on the number of returns I want.
That is where I am:
simulation = -0.2 +0.4 * rand (193.5).;
rowsum = mean (simulation 2);
simulation bsxfun = (@ rdivide, simulation, rowsum);
for i = 1:5
randomR (:, i) = simulation (:, i) * Ynet,.
end
thank you
3 个评论
Image Analyst
2014-4-5
I've read your post 6 times and I can't understand it. Like what does this mean: "I call Ynet (193.1)" What is 193.1? That can't be part of the variable name. We don't know how many more writing errors there might be, so it's best to attach your m-file with the paper clip icon, after you've put in a comment before each line about what that line is supposed to do.
采纳的回答
更多回答(2 个)
Walter Roberson
2014-4-5
mean(simulation, 2)
does not calculate a row sum. You would use sum(simulation, 2) for a row sum
Image Analyst
2014-4-5
Like I said, I can't figure out what you want. You say " I need them (randomR) to be between [-0.25, 0.25] gold mine that is not always the case. Over the size of my matrix randomR must be between 1 and 30". So which is it ? Do you need randomR values to be between -.25 and +.25, OR between 1 and 30?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!