Problems with legend

hello, in my program i have the following plots:
u = [0.4 mnd12005lu];
q = mnd12005sd;
g = [q(1:end-2) ;q(2:end-1); q(3:end)];
t = [0 0 0]; % vektor for de tre første dager (29. des, 1 og 2 jan) for snødybde ved bruk til kristiansentrippel.
zeiglersum = ((2*pi).*mnd12005lu' + 3.6.*mnd12005sd')';
foerdesfaktor = (4.7.*mnd12005lu' + 0.3.*mnd12005sd'.^2)';
grinismaksimum = max(u(1:end-1),u(2:end));
kristiansenstrippel = [mean(t) mean(g)];
hennestadsminimum = min (zeiglersum, grinismaksimum) - 5;
plot (zeiglersum, 'k-')
axis([0 32 -inf inf])
legend ('zeiglersum','foerdesfaktor,'-4.*grinismaksimum', '3.*kristiansenstrippel', 'hennestadsminimum')
hold on
plot(foerdesfaktor, 'm --','linewidth',2)
hold on
plot(-4.*grinismaksimum, 'c : .')
hold on
plot(3.*kristiansenstrippel, 'r -.')
hold on
plot(hennestadsminimum, 'g :')
hold off
When i run the plot, only the legend for 'zeiglersum' shows up. i also get the following message:
Warning: Ignoring extra legend entries. > In legend at 294 In OBLIG2 at 63
OBLIG2 is the program

 Accepted Answer

Walter Roberson
Walter Roberson on 9 Nov 2011

0 votes

Move the legend() call to below the place you plot the last value.
I believe, by the way, that you are missing an "'" immediately after "'foerdesfaktor" in your legend() call.

More Answers (1)

Thomas
Thomas on 9 Nov 2011
Hmm, intial walkthorugh your code
legend ('zeiglersum','foerdesfaktor,'-4.*grinismaksimum',
'3.*kristiansenstrippel', 'hennestadsminimum')
in the legend line you have not completed tick for 'foerdesfaktor'
the line should read:
legend ('zeiglersum','foerdesfaktor','-4.*grinismaksimum', '3.*kristiansenstrippel', 'hennestadsminimum')

1 Comment

peri
peri on 9 Nov 2011
ive changed that and still it wont work

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!