如何把legend放入循环里,试了以下都只显示出一条线,没办法一次画出四条线
n=4
x=-5:0.01:5;
c={'m','g','y','b'} % string vector
n=length(c)
Y=[1;2;3;4]*ones(1,4);
for i=1:n
y=normpdf(x,0,i);plot(x,y,c{i})
%str=strcat('\sigma=',num2str(i));legend(str)Y(i,1))
legend(['sigma=',num2str(i)])
title(['sigma=',num2str(i)])
hold on
end
hold off
%
stringA=printf([],num2str())
legend(striingA)(['sigma='num2str(i,'%d')])
legend(['n_t=' int2str(t)]);