title: skip legend in for loop plot
body: <p>I have a plot which I put inside a for loop as following:</p>
  
  <pre><code>for i=1:300
  
      h3 = figure(3);
      hold on
      h3=plot(MC_Tx{:,i},MC_Ty{:,i},MC_Dx{:,i},MC_Dy{:,i},MC_Mx{:,i},MC_My{:,i})
  plot(Mx_T,My_T,'-mo','MarkerEdgeColor','k','MarkerFaceColor',[.49 1 .63],'MarkerSize',5)
      h3 = title('Target and Missile Trajectory');set(h3,'Interpreter','latex');
      h3 = xlabel('Downrange [m]');set(h3,'Interpreter','latex');
      h3 = ylabel('Altitude [m] ');set(h3,'Interpreter','latex');
      grid on
  
      h4 = figure(4);
      hold on
      plot(MC_Time{:,i},MC_LAMBDT{:,i},MC_Time{:,i},MC_LAMBDD{:,i})
      h4 = title('$$\dot{\lambda_{T}}(t)$$ and $$\dot{\lambda_{D}}(t)$$ vs Time');set(h4,'Interpreter','latex');
      h4 = ylabel('$$\dot{\lambda_{T}}(t)$$ and $$\dot{\lambda_{D}}(t)$$ [rad/s]');set(h4,'Interpreter','latex');
      h4 = xlabel('Time [s]');set(h4,'Interpreter','latex');
      if i == 300
          h4 = legend('$$\dot{\lambda_{T}}(t)$$','$$\dot{\lambda_{D}}(t)$$');set(h4,'Interpreter','latex');
      end
      grid on
  
  end
  </code></pre>
  
  <p>However, most of the lines lay on each other and I can see only 1 of them which is the last ones.</p>
  
  <p>How can I turn on legend only for the last line (Which means for i = 300) while having few figures in the loop?</p>
  
  <p>Thank you!</p>