How to set a column vector as a legend name within multiple plots?
조회 수: 15 (최근 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!