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

FOR-LOOP: Using a for-loop, write the MATLAB code that will determine the value

ID: 3835669 • Letter: F

Question

FOR-LOOP: 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 middot r/1200) An initial investment of $10,000 at a rate of 5.75% for 5 months should output the following WHILE-LOOP: using a while-loop, determine the greatest common divisor (GCD) of two numbers, m and n. GCD = n when mod(m, n) = 0. If mod(m, n) ~ = 0 then reassign values to m and n as follows and try again: temp = m m = n n = mod(temp, n) The above equations use a temp variable in order to preserve the original value of m, which is needed to recalculate and reassign the variable n.

Explanation / Answer

3.

function printCD(P, r, t)
    for i = 1:t
        P = P + P*r/1200;
        fprintf("Month %d : $%.2f ", i, P);
      
    end
end

4.

function b = hcf(a, b)
    if (b > a) %this determines that a is always larger than b
        temp = b;
        b = a;
        a = temp;
    end
  
    while mod(a ,b)~=0
        temp = a;
        a = b;
        b = mod(temp,b);
    end
end

I hope these two function helps you. If you need nore help on this, please ping below