MATLAB: Vectorize sum of discount rates

discount ratevectorization

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! 🙂

Best Answer

R = 5;
cumsum(R.^(0:4))