mathematical optimization - Mathematica Not Saving Variable -


i try perform nested loop not working. it's not saving result in each stage. if replace listinitial print[ ] observer changes made.

any suggestions??

for[b = 1, b < 4, b = b + 1,  for[a = 1, < 4, = + 1,   for[x = 1, x < 4, x = x + 1,    for[z = 1, z < 4, z = z + 1, listinitial =      if[random[] > psurvival,        replacepart[        initialmatrix[3, 3, 3, 3], {b, a, x, z} ->          initialmatrix[3, 3, 3, 3][[b]][[a]][[x]][[z]] - 1],        initialmatrix[3, 3, 3, 3], {b, a, x, z} ->         initialmatrix[3, 3, 3, 3][[b]][[a]][[x]][[z]]]]]]]  listinitial // tableform 

i think problem expect replacepart change initialmatrix. not. change nameless copy of initialmatrix , returns result, assigned listinitial. latter overwritten new value every loop iteration, in end contains result of last replacement. variables equal 3 @ point, last replacement looks like:

initialmatrix[3, 3, 3, 3], {3, 3, 3, 3}->initialmatrix[3, 3, 3, 3][[3]][[3]][[3]][[3]]] 

which doesn't anything. end result listinitial containing started with.

edit
spotted second argument of if statement formatted second instance of replacepart, missing here,


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -