I\'m trying to get this function to work. But i keep getting an error. I am tryi
ID: 3559959 • Letter: I
Question
I'm trying to get this function to work. But i keep getting an error. I am trying to determine the amount in the savings account for next 18 years, which is represented by x(k)
clc,clear
% Variable declaration
% x will be used to store the value of the new balance
% a will be used to store the value of the old balance
% i will be used to store the value of the interest rate
% c will be used to store the value of the user's contribution
% Variable initialization
a = input('Enter a value for the initial balance: ');
i = input('Enter a value for the interest rate: ');
c = input('Enter a value that you will contribute: ');
% Calculation
month = 1:12:216;
for k=1:length(month);
x(k) = a + i(k) + c
end
Explanation / Answer
a = input('Enter a value for the initial balance: ');
i = input('Enter a value for the interest rate: ');
c = input('Enter a value that you will contribute: ');
% Calculation
month = 1:12:216;
s=size(month);
x=zeros(1,s(2));
for k=1:s(2)
x(k) = a+a*i/100 + c;
a=x(k);
end