Vectorize sum of discount rates
显示 更早的评论
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! :-)
采纳的回答
更多回答(3 个)
out=1/(1-R).*(1-R.^(1:n));
Jan
2012-12-6
R = 23;
n = 100;
x = repmat(R, 1, n);
x(1) = 1;
Result = cumsum(cumprod(x));
类别
在 帮助中心 和 File Exchange 中查找有关 R Language 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!