Help with using the solve function given parameters and three equations
Ältere Kommentare anzeigen
Here is my code for an internal rate of return (IRR)
clear
clc
D1=45000;
g1=0.04;
n1=40; %years
D2=-60000;
g2=0.06;
n2=4; %years
D3=-30000;
g3=0.02;
n3=44; %years
syms i
%Benefits: Positive Cash Flows
P1=D1*(((1-(1+g1)^(n1))*(1+i)^-(n1))/(i-g1));
%Costs: Negative Cash Flows
P2=D2*(((1-(1+g2)^(n2))*(1+i)^-(n2))/(i-g2));
%Costs: Opportunity Cost (Lost)
P3=D3*(((1-(1+g3)^(n1))*(1+i)^-(n3))/(i-g3));
i = solve(P1+P2+P3==0,i)
I should be getting an answer that is equal to 7.44%. Instead it is displaying a 42x1 matrix with random numbers. I am trying to get the three equations added together and set equal to zero in order to find i. Please help! I'm sure it's an easy fix.
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 8 Jun. 2016
With those powers of n1 and n3 being 40 and 44, it is not surprising that the solution is a polynomial of about that order. All of those values are mathematical solutions to the equations you set out.
Cutting short the explanations: use
syms i positive
2 Kommentare
Alison Alexsy
am 8 Jun. 2016
Walter Roberson
am 9 Jun. 2016
Use vpasolve() instead of solve()
Kategorien
Mehr zu Numeric Solvers finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!