www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/AddTitleToLegendExample.m

    %% Add Title to Legend
% Plot two lines and create a legend. Then, add a title to the
% legend.

x = -pi:pi/20:pi;
y1 = sin(x);
plot(x,y1)

hold on
y2 = cos(x);
plot(x,y2)
hold off

lgd = legend('sin(x)','cos(x)');
title(lgd,'My Legend Title')