I have generated a matrix of zeros.
tab=Table[0,{i,10},{j,10}]
tab
is defined such that given tab[[1]]
(the first row of tab), I am doing For[i=2,i<=10,i++,tab=ReplacePart[tab,i->2*tab[[i-1]]]]
so that given the first row, all the other rows follow.
Now I have generated another table, tab1
which is a 3x10 matrix of
{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3}}
The problem is to replace the first row of tab
with the first row of tab1
{1,....,1}
and to calculate tab
. Then doing the same with replacing the first row of tab
with the second row of tab1
and then the third row of tab1
. In each realization of the matrix of tab
, I want to calculate the sum of each column and store the result. So in the end, I will have a 3x10 matrix of the sums of columns from each realization. [I am presenting this as a relatively simple problem as in the real problem I am trying to solve, there are about 50000 realizations of the first row of the matrix of dimensions 50x100].
I have tried
For[j = 1, j <= 3, j++, ps[j] = tab1[[j]]];
For[tab[[1]] = ps[j]; i = 2, i <= 10, i++,
tab = ReplacePart[tab, i -> 2*tab[[i - 1]]]];
but its not working. I would appreciate any help. Thank you.
{k, k, k, k, k, k, k, k, k, k}
. Is that correct? $\endgroup$