how to keep adding a varaible in a loop?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Sara Boznik
2021 年 4 月 5 日
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
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!