234k views
5 votes
Write an M-file that will calculate the future worth of an investment for each year from 1 through n by calling a function (that you will need to develop). The input to the function should include the initial investment P, the interest rate i (as a decimal), and the number of years n for which the future worth is to be calculated. b) Run the program for P=$100,000,i=0.05, and n=10 years, by calling the function from the script file using its name. 2 c) Run the program for P=$150,000,i=0.05, and n=10 year by calling the function from the same script file using a function handle. d) Create a plot of the annual balance from year 1 through year 10 , label the axis and provide a title a\&b.

User AllanLRH
by
7.5k points

1 Answer

6 votes

Final answer:

To calculate the future worth of an investment, create an M-file that calls a function taking inputs of initial investment, interest rate, and the number of years. Run the program for specific values and create a plot of the annual balance.

Step-by-step explanation:

To calculate the future worth of an investment for each year from 1 through n, you can create an M-file that calls a function. The function should take inputs including the initial investment (P), the interest rate (i), and the number of years (n). Make sure to develop the function before calling it in the M-file.

For part b), you can run the program for P = $100,000, i = 0.05, and n = 10 years by calling the function from the script file using its name. For part c), you can run the program for P = $150,000, i = 0.05, and n = 10 years by calling the function from the same script file using a function handle.

To create a plot of the annual balance from year 1 through year 10, you can label the axis and provide a title, as mentioned in parts a) and b).

User Sargupta
by
7.6k points