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

need Matlab code for these 2 questions that I am having trouble with....please m

ID: 3850384 • Letter: N

Question

need Matlab code for these 2 questions that I am having trouble with....please make sure it works on Matlab r2016a



Summer 2017 CLASS woRK/HoMEwORK IN CHAPTER 4: Program Flow Control MECH 3500 4.5 The number of years n that it takes to deplete an annuity that starts with an amount P (the principal) by withdrawing an amount A on the first day of each year when the account earns interest at the rate of l annually can be determined from the following relations: After the first day of the first year. the annuity has an amount R P A After the first day of the second year. the annuity has an amount R2 R1 (1+Irl 100) A. After the first day of the third year. the annuity has an amount R3 R201+1 100) A. After the first day of the nth year the annuity has an amount Rn Rn-1 (1+1/100) A A. Determine the number of years that one can withdraw the amount A when P $250.000. I, 4.5%. and A $25,000. Also determine the amount left in the annuity at the beginning of the nth year after A dollars has been withdrawn. Display the results as follows: Principal Annuity Interest No. Remain (S) 45 years (S) 'soooo 25000 12 19112 4.6 The arithmetic-geometric mean process is a means that can be used to evaluate elliptic integrals. For a given a the arithmetic-geometric mean process to obtain the complete elliptic integral is as follows cos a Sin hn-1) 11

Explanation / Answer

PLEASE POST AS SEPARATE QUESTIONS:

4.5) MATLAB CODE:

---------------------------------------------------------------------------------

P = 250000;
Ir = 4.5;
A = 25000;
R = zeros(1,100);
remain = 0;

for years = 1:100
if years == 1
R(1,years)=P-A;
else
R(1,years)=(R(1,years-1)*(1+(Ir/100)))-A;
if R(1,years) < A
remain = R(1,years);
break
end
end
end

remain = round(remain);

disp('Principal Annuity Interest No. Remain')
disp(' ($) ($/yr) (%) years ($) ')
X = sprintf(' %d %d %.2f %d %d',P,A,Ir,years,remain);
disp(X)

--------------------------------------------------------------------------------------------------------

DO THUMBS UP ^_^