Adding a legend manually for a plot generated by a loop
显示 更早的评论
Hi,
I am generating a plot in Matlab one point at a time depending on how a condition is satisfied within a loop:
for i=1:size(Ind,1)
if(Ind(i)==1)
c='ro';
elseif(Ind(i)==2)
c='bo';
elseif(Ind(i)==3)
c='go';
end
plot(i,Y(i),c) %plotting some other value with the color chosen.
hold on
end
How do I add a legend entry to this? I want to associate the index position(1,2 and 3) to red,blue and green in the legend.
Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!