How can I solve for a specific Internal Rate of Return if I have a variable in the matrix used for cashflow irr(cashflow)

The following function creates a n*1 array that will be used by irr(cashflow) to calculate the internal rate of return.
function ansirr = cirr(r)
cashflow = [-down_pmt; r*ppam_gen + oth_tot]
ansirr = irr(cashflow)
end
which takes in a double "-down_pmt" and two n*1 matrices "ppam_gen" & "oth_tot". the variable is r. so if invoke cirr(0.15), as you can see, ppam_gen will be multiplied by 0.15, cashflow will be created, and an irr is calcuated. However, I wated to emulate a "goal-seek"like function that would solve for r given the condition that ansirr = 0.2 for example.
I've tried solve
syms r
solve(irr([-down_pmt; r*ppam_gen + oth_tot]) == 0.2)
and fgoalattain
x = fgoalattain(@cirr, 0, 0.2, abs(0.2))
however, none work. any suggestions.

Answers (0)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Asked:

on 5 Aug 2013

Community Treasure Hunt

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

Start Hunting!