I need to make a function for compound interest using for
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to form a conditional loop to show the growth of money, I put in $1000 and want it to grow by 8% every year for 8 years, but I keep returning the same values.
money=1000;
x=zeros(1,10);
for i=1:10
x(i)=money*1.08
end
댓글 수: 0
채택된 답변
Dyuman Joshi
2024년 4월 19일
In case you want the final output -
format shortg
money=1000;
for k=1:10
money=money*1.08;
end
money
In case you want the output for each year -
n = 10;
money = 1000*ones(1,n+1);
for k=1:n
money(k+1) = money(k)*1.08;
end
disp(money)
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Install Products에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!