A simple issue with legend
이전 댓글 표시
Hello,
I have a really simple question. To my surprise, I am could not help it (I have no idea !!!). When I type
x1=linspace(0,2*pi,1000);y1=sin(x1);y2=cos(x1);h1=plot(x1,y1,'-k');hold on;
plot(x1,0.*x1,'-k');hold on;h2=plot(x1,y2,'-k');legend([h1 h2],{'a','b'});
Then I get the following error message
Invalid argument. Type 'help legend' for more information.
I tried legend([h1 h2],['a','b']); which also does not work.
Sorry to bother you for this, thanks in advance!
댓글 수: 5
It's working here in R2023b and in my R2021b as well.
Which MATLAB version are you working with?
x1=linspace(0,2*pi,1000);
y1=sin(x1);
y2=cos(x1);
h1=plot(x1,y1,'-r');
hold on;
plot(x1,0.*x1,'-k');
hold on;
h2=plot(x1,y2,'-b');
legend([h1 h2],{'a','b'});
Mohammad Shojaei Arani
2023년 11월 17일
Dyuman Joshi
2023년 11월 17일
That should work in R2023a.
For which line do you get the error?
Also, please copy and paste the full error message (i.e. all of the red text), if you have not already.
Mohammad Shojaei Arani
2023년 11월 17일
Mohammad Shojaei Arani
2023년 11월 17일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
