Creating a function using a vector as a variable
Mostrar comentarios más antiguos
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 comentario
Star Strider
el 25 de Abr. de 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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!