Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB For-Loop: Using a for-loop, write the MATLAB cod that will determine the

ID: 3685243 • Letter: M

Question

MATLAB

For-Loop: Using a for-loop, write the MATLAB cod 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 (Note: You MUST format the output the same but DO NOT hardcode 10000, 5.75, or 5)

Month 1:   $10047.92

Month 2:   $10096.06

Month 3:   $10144.44

Month 4:   $10193.05

Month 5:   $10241.89

Explanation / Answer

P = input("Enter amount to invest");
r = input("Enter interest rate");
n = input("Enter number of months");
for i = 1 : n
P = P + P * r / 1200;
X = sprintf('Month %d: $%.2f',i,P);
disp(X)
end