In: Computer Science
MATLAB
Suppose that $2000.00 is left to sit in a bank account that initially pays 7% interest per year, compounded annually. However, if the balance in the account exceeds $10000.00, the interest rate increases to 9%. Write a code that does the calculation of account balance after every year, and stores it in a vector balaceV.
What will be the value of the vector after 30 years of saving? Plot the resulting vector versus time (years), using any style you like (line/points/bars). Make sure that the vector's first value of balance (meaning the initial deposit at time=0) is also included, so the resulting vector for 30 years should contain 31 elements. The x-axis should have values from 0 to 30.
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
balanceV=[2000];
for i=2:31
if(balanceV(i-1)<=10000)
balanceV(i)=balanceV(i-1)*(1.07);
else
balanceV(i)=balanceV(i-1)*(1.09);
end
end
plot(0:30,balanceV);
xlabel('Time');
ylabel('Balance');
title('Plot of balance vs time');
Kindly revert for any queries
Thanks.