Using a forloop write the MATLAB code that will determine th
Using a for-loop, write the MATLAB code that will determine the value of a CD (Certificate of Deposit - like a savings account). Read in the amount to invest (P), the interest rate (r), and the number of months. For each month, output the CD value using the following formula: P = P + (P * r/1200) An initial investment of $10,000 at a rate of 5.75% for 5 months should output the following Month 1:$10047.92 Month 2: $10096.06 Month 3: $10144.44 Month 4:$10193.05 Month 5: $10241.89
Solution
MATLAB CODE:
P = input(\'Enter Investment amount (P) = \');
r = input(\'Enter rate of interest (r) = \');
m = input(\'Enter no. of months = \');
for k = 1:m
CD1 = P+(P*(r/1200));
P = CD1;
x = sprintf(\'Month %d: $%d\',k,CD1);
disp(x)
end
