Making sure values do not get overwritten in Matlab
<p>I am modelling the spread of a disease and I want to make an image which plots the first time an infection occurs in a pixel of a matrix. </p>

<p>So i got this: </p>

<pre><code>for t=1:30
        infected=calc_infected(susceptibles, disease, row, col);
        if t &lt; 8                            % The infection occurs in the first week in these pixels                       
           LM(find(infected &gt; 0))= 2        
        elseif t&gt;=8 &amp;&amp; t&lt;15                 % The infection occurs in the second week in these pixels
            LM(find(infected &gt; 0))= 3;
        elseif t&gt;=15 &amp;&amp; t&lt;22 
            LM(find(infected &gt; 0))= 4;
        elseif t&gt;=22 &amp;&amp; t&lt;30 
            LM(find(infected &gt; 0))= 5;
end 
</code></pre>

<p>T is the time in days. LM is my map on which I plot my data. Infected is the matrix which contains the temporal evolution of the infection. My question is: as I want to show to time the first infection occurs, how can I make sure that the value a pixel does not get overwritten when it becomes infected for the second time, but within another time classification? E.g. if a pixel has already a value of 2 because it got infected at t=5, but it gets infected again at t=25, it can get overwritten by a value of 5.</p>

<p>Thanks already!</p>