Creating a function using a vector as a variable
Ältere Kommentare anzeigen
I'm trying to create a financial calculator, and have it run a calculation N number of times and display the result for each time as a new line in a new array created. I don't know where to start, and I have included the code of what I have so far. The output is only a 100X1 array with the "year" variable.
Thanks, Cameron
function [time,isimple,iperiodic,icontinuous] = interest(P,r,n,t)
time=[1:t]';
isimple=P*(1+(time*r));
iperiodic=P*((1+(r/n)).^(n*time));
icontinuous=P*((exp(1)).^(r*time));
%psimple=p+(isimple.*t);
% Detailed explanation goes here
%isimple,iperiodic,icontinuous
%psimple,pperiodic,pcontinuous
end
1 Kommentar
Star Strider
am 25 Apr. 2014
Does it produce the result you expect?
I suggest that instead of:
exp(1).^x
write:
exp(x)
Same result, and much more efficient.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Dates and Time finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!