Question
I only need B and C. I don't know how to use fzero or bisection to find the months.
0. Taken from Engineering computations, An introduction using MATLAB and Excel). When an amount of money P in invested at an annual interest rate ofI(expressed as a decimal value, not as a percentage), the total value of the investment A after n years can be computed as follows: We wish to find how many years until the investment reaches a desired amount. Test your code for an initial investment of $10,000, a target value of $100,000 and an interest rate of a. Write MATLAB code to find n to the nearest year using a loop. Prompt the user to enter P, the target amount A, and i. Then, loop until the desired amount is reached.
Explanation / Answer
Part B:
%% Solve System of equation in MATLAB
A=100000;
P=10000;
i=0.1;
f = @(n)A-P*(1+i)^n;
Number_of_years = fzero(f,10)
OUTPUT:
>> solve_sys_eqn
Number_of_years =
24.1589
PART c :
PMT() function in Excel verifies above results.