%% Included Subset of Graphics Objects in Legend
% If you do not want to include all of the plotted graphics objects in the legend, then you can specify the graphics objects that you want to include.
% Plot three lines and return the Line objects created. Create a legend that includes only two of the lines. Specify the first input argument as a vector of the Line objects to include.

x = linspace(0,pi);
y1 = cos(x);
p1 = plot(x,y1);

hold on
y2 = cos(2*x);
p2 = plot(x,y2);

y3 = cos(3*x);
p3 = plot(x,y3);
hold off

legend([p1 p3],{'First','Third'})

% Copyright 2012 The MathWorks, Inc.