Vectorize sum of discount rates

2 vues (au cours des 30 derniers jours)
Sargondjani
Sargondjani le 6 Déc 2012
Hi,
I want to vectorize the calculation of series like this: [R^0;R^0+R^1;R^0+R^1+R^2;...etc.
Im quite sure this should be easy, but i cant figure it out. Any help is greatly appreciated! :-)
  1 commentaire
Jan
Jan le 6 Déc 2012
What is "R"?

Connectez-vous pour commenter.

Réponse acceptée

Matt Fig
Matt Fig le 6 Déc 2012
R = 5;
cumsum(R.^(0:4))

Plus de réponses (3)

Matt J
Matt J le 6 Déc 2012
Modifié(e) : Matt J le 6 Déc 2012
out=1/(1-R).*(1-R.^(1:n));

Jan
Jan le 6 Déc 2012
R = 23;
n = 100;
x = repmat(R, 1, n);
x(1) = 1;
Result = cumsum(cumprod(x));

Sargondjani
Sargondjani le 6 Déc 2012
thank you all for you answers... all did what i wanted, but the one by Matt Fig is the most simple

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by