t=0:0.1:10;y=sin(t);x=cos(t);l=plot(t,y,'r-');hold onp=plot(t,x,'g-');[legh,objh,outh,outm]=legend(l,'y',1);legh2=copyobj(legh,gcf);[legh2,objh2]=legend(p,'x',2);