How to set a column vector as a legend name within multiple plots?
14 次查看(过去 30 天)
显示 更早的评论
I have a for loop that creates a figure with 5 plots. I am trying to set a legend so that each plot says "A = 0", "A = 4", "A = 8", etc.
This is the code I have so far:
figure
hold on
for i = 1:N
a1 = [0;4;8;12;16];
x = data(:,2);
v = data(:,4);
v1 = abs(v);
plot(x,v1,'color',rand(1,3))
title('Velocity Distribution')
xlabel('x/c')
ylabel('v')
legend(strcat('Alpha=',num2str(a1')))
end
However, when I do this it doesnt give me 5 legends. It only gives me one legend for one plot:
I want it to read:
(Line 1) A = 0
(Line 2) A = 4
(Line 3) A = 8
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!