필터 지우기
필터 지우기

How would I ask the user to input another option for cash flow and interest rate, then compare the two or three additional options?

조회 수: 1 (최근 30일)
clc;
clear;
close all;
numberYears= input('Planning Horizon Length\n--> ');
cashflows = zeros(numberYears, 1);
for k = 1:numberYears
cashflows(k) = input(sprintf('Cash flow for year %d\n--> ', k));
end
n=length(cashflows);
for i =1:n
x(i) = i-1;
end
ir = input('Input Interest Rate (%)\n-->');
PW= 0;
i = (ir/100)+1;
bar(x,cashflows,0.25)
%Equation for PW analysis
for j= 1:length(i)
PW=0;
for t= 1:n
PW=PW+cashflows(t)*i(j)^(-x(t));
PWA(j,t)=PW;
end
end
%plots CF diagram
figure(1)
hold on
plot(x,PWA,'-x','LineWidth',2)
legend('Cash Flow',num2str(ir),'Location','southeast')
% plot your data
ylabel('Present Worth')
xlabel('Year')
check1 = PWA(end)>0;
answer = ['N','Y'];
fprintf('Is the investment worthwhile? %c\n',answer(check1+1))
It should also ouptut which option is best

답변 (0개)

카테고리

Help CenterFile Exchange에서 Cash Flows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by