MATLAB homework help request
이전 댓글 표시
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
2012년 10월 21일
0 개 추천
Check out input() or better, inputdlg(). Then check out plot().
댓글 수: 11
Ong
2012년 10월 21일
Ong
2012년 10월 21일
Walter Roberson
2012년 10월 21일
TheRandomNumber = rand();
Note that this produces values in the range 2^(-53) to 1-(2^(-53)) -- but at least you didn't have to provide a range.
Ong
2012년 10월 22일
Ong
2012년 10월 22일
Image Analyst
2012년 10월 22일
What other question about the time units? If you need to compute the current balance monthly or daily, then there is a formula for computing balance monthly or daily given an annual interest rate. I'm sure you can find that.
What while loop? I'd use a for loop "for y = 1 : n".
Ong
2012년 10월 22일
Walter Roberson
2012년 10월 22일
What range values are you referring to? I don't understand why you are asking about random numbers at all, as the assignment you posted has no randomness to it.
If you are asking how I know that rand() produces values in the range 2^(-53) to 1-(2^(-53)), then the answer is that I have memorized those limits from documentation for previous MATLAB versions when the ranges were clearly presented instead of being a struggle to find (as they are in the current documentation.)
Ong
2012년 10월 22일
Walter Roberson
2012년 10월 22일
The discussion of your other question should happen in your other question.
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
2012년 10월 21일
I did. 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.
Ong
2012년 10월 21일
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
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!