Filter löschen
Filter löschen

How do i add legend

1 Ansicht (letzte 30 Tage)
jeet Mehta
jeet Mehta am 11 Jun. 2019
Beantwortet: Emmanuel Adesina am 24 Apr. 2021
HI all i am just willing to add legend to the above figure where i just wana involve legend for x1 and data 1 what is the command to type that . this is an SMC controller.

Antworten (2)

Lizhou
Lizhou am 11 Jun. 2019
x = linspace(0,pi);
y1 = cos(x);
p1 = plot(x,y1);
hold on
y2 = cos(2*x);
p2 = plot(x,y2);
y3 = cos(3*x);
p3 = plot(x,y3);
hold off
legend([p1 p3],{'First','Third'})

Emmanuel Adesina
Emmanuel Adesina am 24 Apr. 2021
You can simply plot all as:
plot(x,y1, x,y2, x,y3, ...)
or
line(x,y1)
line(x,y2)
line(x,y3)
...
and add all legend at once.
legend("y1","y2","y3",...)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by