%% Calculate Future Value of Varying Cash Flows
% This cash flow represents the yearly income from an initial investment of $10,000. The annual interest rate is 2%.
% Year 1 — $2000
% Year 2 — $1500
% Year 3 — $3000
% Year 4 — $3800
% Year 5 — $5000
% For the future value of this regular (periodic) cash flow:

FutureVal = fvvar([-10000 2000 1500 3000 3800 5000], 0.02)

% An investment of $10,000 returns this irregular cash flow. The original investment and its date are included. The periodic interest rate is 3%.
% -$1000 — January 12, 2000
% $2500 — February 14, 2001
% $2000 — March 3, 2001
% $3000 — June 14, 2001
% $4000 — December 1, 2001
% To calculate the future value of this irregular (nonperiodic) cash flow:

CashFlow = [-10000, 2500, 2000, 3000, 4000];

CFDates = ['01/12/2000'
            '02/14/2001'
            '03/03/2001'
            '06/14/2001'
            '12/01/2001'];

FutureVal = fvvar(CashFlow, 0.03, CFDates)

% Copyright 2020 The MathWorks, Inc.