| Author |
Comment/Response |
Bill Simpson
|
03/27/12 2:23pm
From the documentation:
ReplacePart[expr,i->new]
yields an expression in which the ith part of expr is replaced by new.
Note that does not say
ReplacePart[expr,i->new]
stores the result of an expression in which the ith part of expr is replaced by new back into the variable expr.
Try storing the result, which is what I think you want.
n=3;
mat=ConstantArray[0,n];
j=0; While[j<n, mat=ReplacePart[mat,j+1->j+1]; j++];
URL: , |
|