Can someone please explain what I’m doing wrong?

3 visualizaciones (últimos 30 días)
Gunjan
Gunjan el 23 de En. de 2024
Comentada: Star Strider el 23 de En. de 2024

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

Respuesta aceptada

Star Strider
Star Strider el 23 de En. de 2024
Editada: Star Strider el 23 de En. de 2024
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 comentarios
Gunjan
Gunjan el 23 de En. de 2024
Thanks a ton!! It did work!!
Star Strider
Star Strider el 23 de En. de 2024
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Legend en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by