So right now, the code I have makes the user input up to an infinite number of values for the cash flow matrix and the intrest rates. How do I allow the user to first input the number of inputs they need, then individually ask the values for each yearly cash flow as well as the interest rates?
clc;clear;close all; A= input('Input cash flow matrix in the form "[yr1 yr2 yr3 yr...] \n"-->'); %Defines a initially after buying the machine
n=length(A);for i =1:n x(i) = i-1;end PW= 0;int=input('Input various intrest rates in the form [a b c...]\n-->');bar(x,A,0.25)hold off %Equation for PW analysis
for j= 1:length(int) PW=0; for t= 1:n PW=PW+A(t)*int(j)^(-x(t)); PWA(j,t)=PW; endend %plots CF diagram
figure(1)hold onplot(x,PWA,'-x','LineWidth',2)legend('CF diagram','Location','southeast')
Current output:
Input cash flow matrix in the form "[yr1 yr2 yr3 yr…]"
–>[-5000 2000 2000 1000] *note these are random numbers I input
Input various intrest rates in the form [a b c…]
–>[1.01 1.02] *note these are random numbers I input
Best Answer