title: Assigning legend in for-loop Matlab
body: <p>I have tried giving the legend in the loop but it overwrites the previously written legend, how can insert them either in if statement or either in the for loop. Confused  </p>
  
  <pre><code>    clear;
          vin=10
   for m=1:1:14;  
  
          vin=vin+10
      for i=1:1:27
          Wa_Ac = PVinv.CoreSizeModel();
          PVinv.CoreSelect(Wa_Ac,i);   
          loss_ind_core= PVinv.InductorLossModel(PVinv.m_L_Selected);
  
          if(i==1)
          p=plot(vin,loss_ind_core,'--gs');
          hold on
          end
          if(i==2)
          p=plot(vin,loss_ind_core,'--rs');
          end %...till i=27
  
          legend(obj.m_Core_List(i).name);
          xlim([10e3 90e3])
          set(gca,'XTickLabel',{'10';'20';'30';'40';'50';'60';'70';'80';'90'})
          grid on
          xlabel('Vin');
          ylabel('Power loss');
      end
   end
  </code></pre>
  
  <p>The called function</p>
  
  <pre><code>function obj = CoreSelect(obj, WaAc)
               obj.m_Core_Available= obj.m_Core_List(i);
              obj.m_L_Selected.m_Core = obj.m_Core_Available;
  
  end 
  </code></pre>