how to keep adding a varaible in a loop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
i have this code which i want to write in a loop because it has to go on for a 1000 or so and i dont know how to make a loop for this inverval
NASDAQ_low = [norminv(1-NASDAQ(1,1)) norminv(1-(AA(1,1)+AA(1,2))) norminv(1-(AA(1,1)+AA(1,2)+ AA(1,3))) norminv(1-(AA(1,1)+AA(1,2)+AA(1,3)+AA(1,4))) norminv(1-(AA(1,1)+AA(1,2)+AA(1,3)+AA(1,4)+AA(1,5)) .... and so on
i also want to do the same for this
exp^LIBOR *(1+X)/(1-X)^2 + exp^LIBOR *(1+X)/(1-X)^2 + (1+X)/(1-X)^3 + exp^LIBOR *(1+X)/(1-X)^2 + (1+X)/(1-X)^3+ (1+X)/(1-X)^4 + exp^LIBOR *(1+X)/(1-X)^2 + (1+X)/(1-X)^3+ (1+X)/(1-X)^4
(1+X)/(1-X)^5 + etc....
could anyone give me a clue?
thank you in advance
0 Kommentare
Antworten (1)
Sara Boznik
am 5 Apr. 2021
First one:
n=1;
suma=0
for n=1:1:1000
AA(1,n)
suma=AA(1,n)+suma;
norminv=1-suma
n=n+1;
end
Second one:
k=2;
suma=0;
for k=2:1:1000;
part=exp^LIBOR *(1+X)/(1-X)^k;
suma=suma+part;
k=k+1
end
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!