f = figure; 
ax = axes(f);
l1 = line(ax,[0 10],[0 10],'color',[0 0 0],'displayname','line1');
l2 = line(ax,[0 10],[10 0],'color',[0 1 0],'displayname','line2');
l = legend(ax,[l1 l2],'autoupdate','off');
set(l2,'ydata',NaN,'visible','off')
legend(ax,l1,'autoupdate','off')
set(l2,'ydata',[5 0],'visible','on','displayname','line2 new')