Create for loop to calculate irr
이전 댓글 표시
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?
답변 (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])
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
