Why do I have different result through ans key?

4 ビュー (過去 30 日間)
Tomás Nunes
Tomás Nunes 2018 年 4 月 4 日
編集済み: Andrew Newell 2018 年 4 月 4 日
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 件)

カテゴリ

Help Center および File ExchangeFractals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by