How do I create a legend and include loop variable values in the labels while plotting a Matrix ?
이전 댓글 표시
u = 1:2:10;
z_x = 1:10;
temp = [1:10;11:20;21:30;31:40;41:50];
figure,
hold on
for l= 1:length(u)
str = ['S = ',num2str(u(l))];
plot(temp,z_x,'DisplayName',str);
end
legend show
The above code displays one value of S multiple times. Since i'm plotting a matrix and want to produce a legend for each uniques curve only one. What correction should I make so that the each S value is displayed only once in the legend.
댓글 수: 4
madhan ravi
2020년 6월 19일
It is producing what you asked for? if not elaboarate more say for example what you want in one iteration the legend to be?
KSSV
2020년 6월 19일
Is it not your plot is messy? What exactly you want? Why you would want to plot a matrix?
AKRITI KOTHIALA
2020년 6월 19일
편집: AKRITI KOTHIALA
2020년 6월 19일
AKRITI KOTHIALA
2020년 6월 19일
편집: AKRITI KOTHIALA
2020년 6월 19일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!