here's my code:
for j=1:tmax
for i=1:n if mat(i)==0 && rand() < r*(1-(zerfre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)=mat(idx); elseif mat(i)==1 && rand() < r*(1-(onefre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)= mat(idx); elseif mat(i)==2 && rand() < r*(1-(twofre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)= mat(idx); elseif mat(i)==3 && rand() < r*(1-(thrfre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)= mat(idx); elseif mat(i)==4 && rand() < r*(1-(foufre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)= mat(idx); elseif mat(i)==5 && rand() < r*(1-(fivfre)^2); idx = 1 + fix(rand(1,1)*numel(mat)); mat(i)= mat(idx); end last(i,i)=? end
Basically, I have a nxn matrix (which is mat here) with entries as integers from 0 to 5. I'm going to update each entry of the matrix with the rules written in my for loop.
as an output I want a nxn matrix (which I called last here) with the entries updated after tmax iterations with the written rules. So, it's storing data from a for loop. But I can't figure out how I would construct the output nxn matrix. Thanks a lot!
Best Answer