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?

Réponses (1)

Torsten
Torsten le 28 Avr 2023
Modifié(e) : Torsten le 28 Avr 2023
syms r n N
symsum(1/(1+r)^n,n,1,N)
ans = 
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])
r = 0.0566

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Tags

Modifié(e) :

le 28 Avr 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by