Create for loop to calculate irr
Show older comments
I am currently trying to calculate the IRR for a set number of NNV values.
I have created a formula for calculating the NNV, which is:
syms n
NNV=round(-ko+symsum(tot_profit./((1+r)^n),n,1,30))
-Where r is the rate
-n goes between 1 and 30
-tot_profit is a matrix of 20 different profits
I was thinking about creating a for loop that can go through all the different values and find the IRR (which is the rate at which NNV=0), but i don't know how to set this up. Does anyone know of a good way to solve this?
Answers (1)
syms r n N
symsum(1/(1+r)^n,n,1,N)
ko = 100;
tot_profit = 7;
n = 30;
fun = @(r) -ko + tot_profit* ((r+1)^n-1)/(r*(r+1)^n);
r = fzero(fun,[0.01 0.2])
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!