-1
$\begingroup$

I have

pnew[i_] := For[tab[[1]] = tabn[[i]]; j = 2, 
               j <= 6, j++, 
               tab = ReplacePart[tab, j -> (1 + al) x tab[[j - 1]] + sigma x epsilon[[j - 1]]*tab[[j - 1]]]] 

where tab is a 5x5 matrix of zeros,

epsilon={{1, 1, 1, 1, 1}, {2, 2, 2, 2, 2}, {3, 3, 3, 3, 3}, 
         {4, 4, 4, 4, 4}, {5, 5, 5, 5, 5}} 

and

tabn={{1, 1, 1, 1, 1}, {2, 2, 2, 2, 2}, {3, 3, 3, 3, 3}}

al and sigma are constants: al = 0.5; sigma = 0.1;

The question is that I want to find a tab matrix each time by having the first row replaced by one of the rows of tabn. In this example, I would get the tab matrix 3 times and I want one big matrix with all 3 realizations of tab.

I have tried tab /@ pnew[1] and then evaluated tab...but this gives me only one (the first) realization of tab. I have tried tab # &/@[pnew[i],{i,1,3}] but it doesn't work. Any help would be appreciated.

$\endgroup$
  • $\begingroup$ What is x ? ... $\endgroup$ – Dr. belisarius Dec 18 '15 at 6:30
  • $\begingroup$ I am sorry I meant x to be the multiplication sign $\endgroup$ – Supratim Das Gupta Dec 18 '15 at 17:35
  • $\begingroup$ well, not in Mathematica $\endgroup$ – Dr. belisarius Dec 18 '15 at 17:39
2
$\begingroup$

Initializing the tab matrix

tab = ConstantArray[0, {5, 5}];

Defining the rules for second row onwards

rule[j_] := j -> (1 + al) * tab[[j - 1]] + sigma*epsilon[[j - 1]]*tab[[j - 1]]

bigMat stores the full set of results

bigMat = Table[
              tab = ReplacePart[tab, {1 -> tabn[[i]]}];
              res[i] = Last@Table[
                                 tab = ReplacePart[tab, {rule[j]}], {j, 2, 6}
                                 ],{i, 1, 3}
              ]

The individual matrices are stored in res[i]

$\endgroup$
  • $\begingroup$ Hello, thank you very much. I would try your suggestion. $\endgroup$ – Supratim Das Gupta Dec 18 '15 at 17:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.