Write a MATLAB code to solve the following difference equations by z-transform and display the solutions by stem plots:
3) A bank account gives an interest rate of 5% compounded monthly. If you invest initially Rs .1000 and add Rs. 10 every month. How much money do you have after 5 years?
syms p(n) z
r = (5/100)/12
Pr=1000
u=10
assume(n>=0 & in(n,'integer'))
f = Pr*((p(n+1) - p(n) - r*p(n)) ) - u
fZT = ztrans(f,n,z)
syms pZT
fZT = subs(fZT,ztrans(p(n),n,z),pZT)
pZT = solve(fZT,pZT)
pSol = iztrans(pZT,z,n);
pSol = simplify(pSol)
pSol = subs(pSol,[p(0) p(1)],[1 2])
nValues = 1:60;
pSolValues = subs(pSol,n,nValues);
pSolValues = double(pSolValues);
pSolValues = real(pSolValues);
stem(nValues,pSolValues)
title('Compounded Amount Plot')
xlabel('Month (n)')
ylabel('Compounded AMount p(n)')
grid on
Comments
Leave a comment