t = 0 : 0.01 : 2 * pi;
s = sin(t);
c = cos(t);
m = -sin(t);
hold on;
plot(t, s, \'r\');
plot(t, c, \'b\');
plot(t, m, \'g\');
hold off;
legend(\'\', \'cosine\', \'
You could just change the order in wich the curves are plotted and apply the legend to the first curve:
t = 0 : 0.01 : 2 * pi;
s = sin(t);
c = cos(t);
m = -sin(t);
plot(t,c,t,s,t,m) % cosine is plotted FIRST
legend('cosine') % legend for the FIRST element
if i'd want to put in a legend for cosine and -sine:
plot(t,c,t,m,t,s) % cosine and -sine are first and second curves
legend('cosine', '-sine')