Why do I have different result through ans key?

1 Ansicht (letzte 30 Tage)
Tomás Nunes
Tomás Nunes am 4 Apr. 2018
Bearbeitet: Andrew Newell am 4 Apr. 2018
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

Antworten (0)

Kategorien

Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by