MATLAB: Multiplying cells within a matrix

multiplication within a matrixsimulated stock values and returns

Hello I am very new to Matlab and have occurred a problem i can not seem to sort by myself.I have a very large matrix of simulated stock index returns and I want to convert the returns to simulated stock index values. I will use a small matrix to illustrate my problem;
A = [ 100, 100, 100; (1+0.04), (1+0.03), (1+0.1); (1+0.02),(1+0.07), (1+0.06)] The first row is the start value of the stock index, the second and third row are daily simulated stock returns. Each colummn is an simulation. My goal is to get a 2×3 matrix that shows the simulated value of the stock index at each day. In this example it would be: B=[100*(1.04), 100*(1+0.03), 100*(1+0.1); 100*(1.04)* (1+0.02), 100*(1+0.03)*(1+0.07), 100*(1+0.1)*(1+0.06)] I have tried for-loops but have not made any succcess.Sorry for not posting any code but I do not have anything that is close.. Would really appreciate any help Kind regards Sveinung Tyssedal

Best Answer

doc cumprod
iwant = cumprod(A) ;
iwant(1,:) = [] ;