Why do I have different result through ans key?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to compute maximum drawdowns within a vector, but the for loop gives me wrong results. Basically I have a vector called portfolio with cumulative returns and another vector called rows_cycle that gives me the rows for which i should compute the maxdrawdown. The code is:
letstry = zeros(length(rows_cycle)-1,1);
for i = 2:1:length(rows_cycle)
letstry(i-1,1) = maxdrawdown(portfolio(rows_cycle(i-1:i)));
end
the problem is that if I put maxdrawdown(portfolio(233:358)), it gives me a different result from maxdrawdown(portfolio(rows_cycle(3-1:3))), when rows_cycle(2:3) = 233:358
Even if I compute first rows_cycle(2:3) and then maxdrawdown(portfolio(ans)), the results are different from maxdrawdown(portfolio(233:358)).
What's wrong with the loop? thx
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!