필터 지우기
필터 지우기

How many years to double initial investment with various interest rates

조회 수: 1 (최근 30일)
Jared Watkins
Jared Watkins 2019년 8월 2일
답변: David K. 2019년 8월 2일
S = P(1+i)^n
trying to create a table that shows interest rates and how many years too double

답변 (1개)

David K.
David K. 2019년 8월 2일
If I understand the equation you posted correctly lets walk through this. S = total amount after n years if P was initially invested at i interest rate.
So first off we want this equation to be n = function of i.
To get rid of P and S we state that P needs to be double so S = 2P and if we divide P over we get the equation
2P = P(1+i)^n
2 = (1+i)^n
Now we take the log of both side, I am going to use the natural log, ln, because Matlab's basic log function is actually the natural log. Then use a log property that lets me remove the exponent and then divide to both sides:
ln(2) = ln((1+i)^n)
ln(2) = n*ln(1+i)
n = ln(2)/ln(1+i)
Now that we have an equation we can put it into Matlab for various interest rates
intRates = .01:.01:.20; % array Interest rates from 1 to 20%
years2double = log(2)./log(1+intRates); % Calculate years to double
% This will create a table with whatever names you want
table(intRates',years2double','VariableNames',{'intRates','years2double'})
% Here is a plot if you want that
plot(intRates,years2double)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by