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!