title: Store a fixed value in the variable only once
body: <p>I have a variable in my code called p_fix. It is necessary to save the value of this variable when PE&gt;p. But the way I did it, every time PE&gt;p is respected, the value of this variable is changed, how can I save its value only once when PE&gt;p and never change the value of this variable (p_fix) again?</p>
  <pre><code>for n = 1:size(t,1)
   if  n&gt;=4
       X = [Ia(n-1,1) Ia(n-2,1) ; Ia(n-2,1) Ia(n-3,1)];
       future = [Ia(n,1) ; Ia(n-1,1)];
       C = X\future;
       Ia_future(n,1) = C(1,1)*Ia(n,1)+C(2,1)*Ia(n-1,1);
       PE(n,1)=Ia(n,1)+Ia_future(n,1);
       p(n,1)=(1+0.2)*max(PE(n-1,1));
       
   if  PE(n-1,1)&gt;p(n,1)
       p_fix = p(n,1);
  
        end
     end
  end
  </code></pre>