- #1
spoonyluv
- 9
- 0
Hello,
I am trying to store the results in the form of an array every time the code goes through a loop. This is what my code looks like:
for j = 1:100
for i= 1:100
if S(i)==0
if rand < T
S(i)= 1;
t_inf(i) = j;
end
else
if S(i)== 1
if j-t_inf(i) > duration
S(i) = 2;
end
end
end
end
end
So basically for the loop j =1:100, everytime the code goes through the j loop (for 100 times) and looks into the i loop and changes/does not change it, I would like to store the results of the change/non change for each loop. How do I do that? how can I store and view the results for each j loop? And the reason I want to do this is that I want to plot the results of each loop to see how many 0, 1, 2's I have over time...
I am trying to store the results in the form of an array every time the code goes through a loop. This is what my code looks like:
for j = 1:100
for i= 1:100
if S(i)==0
if rand < T
S(i)= 1;
t_inf(i) = j;
end
else
if S(i)== 1
if j-t_inf(i) > duration
S(i) = 2;
end
end
end
end
end
So basically for the loop j =1:100, everytime the code goes through the j loop (for 100 times) and looks into the i loop and changes/does not change it, I would like to store the results of the change/non change for each loop. How do I do that? how can I store and view the results for each j loop? And the reason I want to do this is that I want to plot the results of each loop to see how many 0, 1, 2's I have over time...