Can someone please explain what I’m doing wrong?

2 ビュー (過去 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 Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by