how to keep adding a varaible in a loop?

1 view (last 30 days)
L Mllr
L Mllr on 5 Apr 2021
Commented: L Mllr on 6 Apr 2021
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

Answers (1)

Sara Boznik
Sara Boznik on 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

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!