How to omit legend entry

98 views (last 30 days)
victoria yap
victoria yap on 14 Sep 2015
Commented: Star Strider on 15 Sep 2015
I am trying to omit the legend entry for graph b, but the following code still shows the curve in the legend. Thanks!
a = @(x) sin(x)
fplot (a,[1,10])
hold on
b = @(x) cos (x)
fplot (b,[1,10])
c = @(x) tan (x)
fplot (c,[1,10])
legend ('sinx','','tanx')

Accepted Answer

Star Strider
Star Strider on 14 Sep 2015
The fplot function won’t let you do that, but plot will:
x = linspace(1,10);
a = @(x) sin(x);
ha = plot (x,a(x));
hold on
b = @(x) cos (x);
hb = plot (x,b(x));
c = @(x) tan (x);
hc = plot (x,c(x));
legend ([ha hc],'sinx','tanx')
  2 Comments
victoria yap
victoria yap on 15 Sep 2015
Thanks Star Strider! Works! :)
Star Strider
Star Strider on 15 Sep 2015
My pleasure!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!