Skip to content

Instantly share code, notes, and snippets.

@dangpzanco
Last active November 11, 2016 13:56
Show Gist options
  • Save dangpzanco/7742ba221125835a8a894dcec962fdc6 to your computer and use it in GitHub Desktop.
Save dangpzanco/7742ba221125835a8a894dcec962fdc6 to your computer and use it in GitHub Desktop.
clc
clearvars
close all
i = 0.1;
n = 10;
f1 = [800 0 0 0 0 600 0 0 0 0 600];
f2 = [1400 40 40 40 40 40 20 20 20 20 20];
pvvar(f1,i)
pvvar(f2,i)
i = linspace(0.01,0.1,100);
for j=1:100
vpl1(j) = pvvar(f1,i(j));
vpl2(j) = pvvar(f2,i(j));
end
plot(100*i,vpl1,100*i,vpl2)
grid on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clearvars
close all
tma = 0.1;
units = 7e3;
price = 12;
cost = 10;
n = 15;
irf = 0.3;
% Fluxo de caixa inicial
fci = [-100e3, units*(price-cost)*ones(1,n-1), units*(price-cost)+10e3]'
% Depreciacao linear total em 15 anos
depr = [0, (90e3-0)/n*ones(1,n)]'
% Fluxo de caixa tributavel
fct = fci - depr
% Imposto de renda
imposto = [0, fct(2:end)'*irf]'
% Fluxo de caixa final
fcf = fci - imposto
% Valor presente liquido
vpl = pvvar(fcf,tma)
max_units = 10e3;
for units=1:max_units
% Fluxo de caixa inicial
fci = [-100e3, units*(price-cost)*ones(1,n-1), units*(price-cost)+10e3]';
% Depreciacao linear total em 15 anos
depr = [0, (90e3-0)/n*ones(1,n)]';
% Fluxo de caixa tributavel
fct = fci - depr;
% Imposto de renda
imposto = [0, fct(2:end)'*irf]';
% Fluxo de caixa final
fcf = fci - imposto;
% Valor presente liquido
vpl(units) = pvvar(fcf,tma);
end
units = (1:max_units);
plot(units,vpl,units,max(vpl)*(vpl > 0))
grid on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment