MATLAB homework help request

4 次查看(过去 30 天)
Ong
Ong 2012-10-21
I need help with this question!
The lump sum S to be paid when interest on a loan is compounded
annually is given by S = P(1 + i)n where P is the principal invested,
i is the interest rate, and n is the number of years. Write a function
interest.m that will plot the amount S as it increases through the
years from 1 to n. The main function will call a function to prompt
the user for the number of years (and error-check to make sure that the
user enters a positive integer). The function will then call a function
that will plot S for years 1 through n. It will use .05 for the interest
rate and $10,000 for P.

回答(2 个)

Image Analyst
Image Analyst 2012-10-21
Check out input() or better, inputdlg(). Then check out plot().
  11 个评论
Ong
Ong 2012-10-22
I was thinking of while loop..but again, if I do use that I cant figure out the condition.
Walter Roberson
Walter Roberson 2012-10-22
The discussion of your other question should happen in your other question.

请先登录,再进行评论。


Matt J
Matt J 2012-10-21
编辑:Matt J 2012-10-21
Should be easy. Use the INPUT command to get the user input. Then
if isnumeric(n) && isreal(n) && n>=0
etc...
end
Then apply the compounding formula. Then the PLOT command.
  4 个评论
Ong
Ong 2012-10-21
Its not working! Do you have the solution to provide me with so that I can check where went wrong?
Matt J
Matt J 2012-10-21
I do not. However, you can step through the code 1 line at a time and examine the results by setting breakpoints

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by