From: Sari W on
I am working on Financial calculation to get Net Present Value
In Matlab, I am using pvvar function to obtain this. But in excel when I try to verify the result using NPV function, the results do not match.

Example:
In Excel x= NPV(0.1,1000,2000,3000,400) gives 5089
In Matlab x=pvvar([1000 2000 3000 400],0.1) returns 5891

Why this differenc? Has anybody faced a similar issue?
From: the cyclist on
"Sari W" <sariwaikar(a)gmail.com> wrote in message <hpjrdm$ai6$1(a)fred.mathworks.com>...
> I am working on Financial calculation to get Net Present Value
> In Matlab, I am using pvvar function to obtain this. But in excel when I try to verify the result using NPV function, the results do not match.
>
> Example:
> In Excel x= NPV(0.1,1000,2000,3000,400) gives 5089
> In Matlab x=pvvar([1000 2000 3000 400],0.1) returns 5891
>
> Why this differenc? Has anybody faced a similar issue?

I think you may benefit from a careful reading of the help files for both the Excel and MATLAB functions. They are quite explicit in how they perform the calculation.

Note, in particular, that the first cash flow in MATLAB is considered to be an initial cash flow, whereas in Excel it is a cash flow after one period. You mimic your Excel calculation if you append a "0" at the beginning of your MATLAB cash flow vector:

x=pvvar([0 1000 2000 3000 400],0.1)

Also, as an aside, I recommend you use a more intuitive variable name than "x".

the cyclist