Can someone please explain what I’m doing wrong?

조회 수: 3 (최근 30일)
Gunjan
Gunjan 2024년 1월 23일
댓글: Star Strider 2024년 1월 23일

Neither my xlabel command in line 4 is working nor the legend command

채택된 답변

Star Strider
Star Strider 2024년 1월 23일
편집: Star Strider 2024년 1월 23일
The semicolon in the legend call is wrong (in this context).
It would be better to write all that as a script rather than in the Command Window.
When you do that, it works —
x = -5:0.1:5;
s = sin(x);
c = cos(x);
plot(x,s, x,c)
xlabel('x')
ylabel('sine or cosine')
legend('sine','cosine')
EDIT — Corrected typographical errors.
.
  댓글 수: 2
Gunjan
Gunjan 2024년 1월 23일
Thanks a ton!! It did work!!
Star Strider
Star Strider 2024년 1월 23일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by