Why do I have different result through ans key?

조회 수: 3 (최근 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 CenterFile Exchange에서 Fractals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by