MATLAB Projects DISCUSSION

Matlab internal rate of return

Started by syedzainnasir Matlab internal rate of return
1 replies 248 views 2 participants
Latest activity · 20 Feb 2017

Matlab internal rate of return

syedzainnasir MATLAB Projects Forum
#1
You'll have to be easy on me, I am new to matlab and SO. I am having an issue using the matlab solver to calculate internal rate of return(IRR). I saw that the financial toolbox in matlab had a function for this, however I don't believe I have it installed and did not want to get the trial version on their site.

Given the simple nature of my particular IRR calculation, I figured it would be easy enough to simply code in matlab. It is the same yearly cashflow, so what I put into matlab was as follows:
[code]syms x k; IRR = solve(investment == yrSavings* symsum((1+x)^-k,1, nYears));[/code] It doesn't fail, and in fact gives a number. The only problem is the the result is incorrect! I type in the IRR manually and it never equals the investment. Using wolframalpha I found the actual solution, went back and manually typed in wolframalpha's answer, and the symsum function returned the correct result. I'm not sure what's up with the solver!

Community replies 1

Re: Matlab internal rate of return

#2
[quote=Lucille post_id=101 time=1487593470 user_id=73] You'll have to be easy on me, I am new to matlab and SO. I am having an issue using the matlab solver to calculate internal rate of return(IRR). I saw that the financial toolbox in matlab had a function for this, however I don't believe I have it installed and did not want to get the trial version on their site.

Given the simple nature of my particular IRR calculation, I figured it would be easy enough to simply code in matlab. It is the same yearly cashflow, so what I put into matlab was as follows:
[code]syms x k; IRR = solve(investment == yrSavings* symsum((1+x)^-k,1, nYears));[/code] It doesn't fail, and in fact gives a number. The only problem is the the result is incorrect! I type in the IRR manually and it never equals the investment. Using wolframalpha I found the actual solution, went back and manually typed in wolframalpha's answer, and the symsum function returned the correct result. I'm not sure what's up with the solver! [/quote]
The way you have the formula written, the symbolic assumption is that you are using x as the iterator variable. I believe you want to use k. Try this:
[code]syms x k; IRR = solve(investment == yrSavings* symsum((1+x)^-k,k,1, nYears));[/code] Read More: [url=http://www.theengineeringprojects.com/2014/12/financial-calculations-in-matlab.html]FINANCIAL CALCULATIONS IN MATLAB[/url]
TEP COMMUNITY