Write a MATLAB code to solve the following difference equations by z-transform and display the solutions by stem plots:
1) An amount of USD 10,000 $ is deposited in a bank account with an annual interest
rate of 4%. Determine the balance of the account after 15 years.
close all,
clear all,
clc,
% An amount of USD 10,000 $ is deposited in a bank account with an annual interest
% rate of 4%. Determine the balance of the account after 15 years
syms n
P = 10000;
R = 4;
T = 15;
f = P*(1+(R*n)/100);
Z_Transform = ztrans(f)
f(15) = iztrans(Z_Transform);
A=[];
for n=1:T
A(n) = P*(1+(R*n)/100);
end
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
stem(A);
xlabel('--- Years (n) --->');
ylabel('--- Amount --->');
title('Stem Plot of Growth','FontSize',20);
grid on
disp(['Amount after ',32,num2str(T),32,'years = ',32,num2str(A(T))]);
"Z-Transform = 10000*\\frac{z}{z-1} + 400*\\frac{z}{(z-1)^2}"
Final Output:
Amount after 15 years = 16000
Comments
Leave a comment