Help with using the solve function given parameters and three equations
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
Walter Roberson
2016년 6월 8일
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
카테고리
도움말 센터 및 File Exchange에서 Numeric Solvers에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!