今天看财务内部收益率,无聊的,就用MATLAB花了下曲线(#.#)。好久没碰过MATLAB,真实连最基本的语言格式都忘了。
财务净现值函数曲线FNPV(i)
例子
- 现金流量表
- 现金流量图
- 财务净现值与折现率的函数曲线
- 本例MATLAB绘图程序
i=(-10:0.5:30)/100; % 折现率
i_all=length(i); % 折现率的数目
n=10; % 总年数
CICO=[0 -4 -4 -4 -5 5 5 5 5 5]; % 假定的净现金流量
FNPV=zeros(1,i_all); % 财务净现值,是i的函数
for is=1:1:i_all % 计算
i_temp=i(1,is);
for t=1:1:n
FNPV(1,is)=FNPV(1,is)+CICO(1,t)*(1+i_temp)^(-t);
end
end
% 绘图
figure;
plot(i,FNPV,'r','linewidth',3);
hold on;
plot(i,FNPV*0,'b','linewidth',1.5);
plot([0,0],[min(FNPV)*1.5,max(FNPV)*1.1],'b','linewidth',1.5);
%
ylim([min(FNPV)*1.5,max(FNPV)*1.1]);
set(gca,'Position',[.14 .16 .82 .81],'FontName','宋体','FontSize',14,'LineWidth',1.5);
xlabel('折现率i','FontSize',20,'FontWeight','normal','Color','black');
ylabel('FNPV','FontSize',20,'FontWeight','normal','Color','black');
set(gca,'XMinorTick','on');set(gca,'YMinorTick','on');
转载于:https://www.jianshu.com/p/5b9f696a156d