# pvvar

Present value of varying cash flow

## Description

calculates present value of a varying cash flow.`PresentVal`

= pvvar(`CashFlow`

,`Rate`

)

adds an optional argument for `PresentVal`

= pvvar(___,`CFDates`

)`CFDates`

.

## Examples

### Calculate Present Value for Regular and Irregular Cash Flow

Calculate the net present value for a regular and irregular cash flow.

**Regular Cash Flow**

This cash flow represents the yearly income from an initial investment of $10,000. The annual interest rate is 8%.

Year 1 - $2000

Year 2 - $1500

Year 3 - $3000

Year 4 - $3800

Year 5 - $5000

To calculate the net present value of this regular cash flow:

PresentVal = pvvar([-10000 2000 1500 3000 3800 5000], 0.08)

PresentVal = 1.7154e+03

**Irregular Cash Flow**

An investment of $10,000 returns this irregular cash flow. The original investment and its date are included. The periodic interest rate is 9%.

January 12, 1987 - ($10000)

February 14, 1988 - $1500

March 3, 1988 - $2000

June 14, 1988 - $3000

December 1, 1988 - $4000

To calculate the net present value of this irregular cash flow:

CashFlow = [-10000, 1500, 2000, 3000, 4000]; CFDates = ['01/12/1987' '02/14/1988' '03/03/1988' '06/14/1988' '12/01/1988']; PresentVal = pvvar(CashFlow, 0.09, CFDates)

PresentVal = -768.1461

The net present value of the same investment under different discount rates of 7%, 9%, and 11% is obtained by:

PresentVal = pvvar(repmat(CashFlow,3,1)', [.07 .09 .11], CFDates)

PresentVal =1×310^{3}× -0.5099 -0.7681 -1.0146

## Input Arguments

`CashFlow`

— Cash flow amounts

vector

Cash flow amounts, specified as a vector of varying cash flows. Include the initial
investment as the initial cash flow value (a negative number). If
`CashFlow`

is a matrix, each column is treated as a separate
cash-flow stream.

**Data Types: **`double`

`Rate`

— Periodic interest rate

decimal

Periodic interest rate, specified as a decimal. If `CashFlow`

is
a matrix, a scalar `Rate`

is allowed when the same rate applies to all
cash-flow streams in `CashFlow`

. When multiple cash-flow streams
require different discount rates, `Rate`

must be a vector whose length
equals the number of columns in `CashFlow`

.

**Data Types: **`double`

`CFDates`

— Indicates irregular cash flow

datetime array | string array | cell array of date character vectors

(Optional) Indicates irregular cash flow, specified as a datetime array, string array, or cell array of date character vectors on which the cash flows occur.

Specify `CFDates`

when there are irregular (nonperiodic) cash
flows. The default assumes that `CashFlow`

contains regular
(periodic) cash flows. If `CashFlow`

is a matrix, and all cash-flow
streams share the same dates, `CFDates`

can be a vector whose length
matches the number of rows in `CashFlow`

. When different cash-flow
streams have different payment dates, specify `CFDates`

as a matrix the
same size as `CashFlow`

.

To support existing code, `pvvar`

also
accepts serial date numbers as inputs, but they are not recommended.

**Data Types: **`cell`

| `string`

| `char`

| `datetime`

## Output Arguments

`PresentVal`

— Present value

numeric

Present value, returns the net present value of a varying cash flow. Present value is calculated at the time the first cash flow occurs.

## Version History

**Introduced before R2006a**

### R2022b: Serial date numbers not recommended

Although `pvvar`

supports serial date numbers,
`datetime`

values are recommended instead. The
`datetime`

data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.

To convert serial date numbers or text to `datetime`

values, use the `datetime`

function. For example:

t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)

y = 2021

There are no plans to remove support for serial date number inputs.

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)