£1000 was deposited in a bank account that pays 4% interest annually. The balance will grow as follows: balance = current balance + 0.04*(current balance)
a) use for loop to calculate account balance from year 1 to year 20
b) plot of annual balance from year 1 to year 10, adding axis to the graph
c)print to the screen the balance (2 d.p) at year 10
your message should displace " your account balance after 10 Years is £1480.24"

댓글 수: 5

Guillaume
Guillaume 2017년 3월 31일
So, what efforts have you made towards writing the 6 lines or so required to solve this extremely easy homework?
Harry Chichi
Harry Chichi 2017년 3월 31일
i've tried but i can't seem to get the loop right. the code when run goes all the way to infinity.
Guillaume
Guillaume 2017년 3월 31일
Steven Lord
Steven Lord 2017년 3월 31일
Show us what you've written and we may be able to point out the problem that's causing your loop to run infinitely.
Adam
Adam 2017년 3월 31일
If you are going to edit away your questions after they get answered then don't expect people to be in a hurry to answer your future questions.
People are more than willing to help when you show some effort, but this forum is for people to be able to search and find existing answers to questions they have also. That isn't possible if people just edit away their question as soon as they have been given an answer and it annoys those who gave their time to provide that answer.

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2017년 3월 31일
편집: Guillaume 2017년 3월 31일

0 개 추천

1) You were asked to use a for loop, not a while loop.
2) While you could indeed use a while loop, that loops must end after 20 years. Your loop runs while the balance is greater than 20. This is of course forever since the balance start greater than 20 and keeps growing.

댓글 수: 4

Harry Chichi
Harry Chichi 2017년 3월 31일
Can you please elaborate on point 2, how would I change the code to alter with reference to the number of years rather than the current balance?
Thanks
Guillaume
Guillaume 2017년 3월 31일
Well, which variable do you use to count the years? Make sure that it stays under 20 in the while loop by translating while numberofyears is less than or equal to 20 into matlab code. It's not that hard.
Steven Lord
Steven Lord 2017년 3월 31일
Use the plot function.
Elisabeth Quan
Elisabeth Quan 2021년 9월 27일
why are the "experts" on this site so rude and dismissive?! i.e.: Guillaume saying "it's not that hard." Maybe it's not that hard FOR YOU because this is a subject that you understand, but this language is very counterintuitive and frustrating.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2017년 3월 31일

댓글:

2021년 9월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by