Im creating a function to output future value of invested money by F=P*(1+(i/1200))^n, where i us interest rate, P is initial invested money, and n is the number of months. I need to input P,i,and n, which i have done. I need to get both the months and future values to display in side by side columns like this:
Month Future Value
===== ============
1 $502.08 2 $504.18
and so on..
Here's what I've been able to come up with:
fid=fopen('interest.txt','w');P=input('Enter initial investment: ');i=input('Enter investment interest rate(in %): ');x=input('Enter investment period(in months): ');fprintf('Output file sucessfully created.')for n=1:xF=P*(1+(i/1200))^nendfclose(fid)fid=fopen('interest.txt','r');[n F]=fscanf(fid,'%d');fclose(fid);disp(n)disp(F)
I don't know why the months and Future values aren't displaying, but the Future value from the for loop does. but more importantly, how should i be displaying this. I'm assuming fprintf but i cant get the F and N to display.
Best Answer