Dynamic Legend in MatLab

by S_David
Tags: dynamic, legend, matlab
S_David is offline
Nov28-11, 05:42 PM
P: 590

I am trying to do the following:

for i=1:3
legend('i legend1','i legend2',''i legend1'')

where I need to draw the same plots under different settings, such that each function has the same color under the different settings, but with different style, e.g: solid line in the first, dotted in the second, ... and so on. I also want to include the number i in the legend at each iteration. How to do that?

Phys.Org News Partner Science news on Phys.org
Internet co-creator Cerf debunks 'myth' that US runs it
Astronomical forensics uncover planetary disks in Hubble archive
Solar-powered two-seat Sunseeker airplane has progress report
a-tom-ic is offline
Dec2-11, 06:29 PM
P: 33
I'm not that sure that i understood what you wanted, however this thread came into my mind:
jhae2.718 is offline
Dec2-11, 06:34 PM
PF Gold
jhae2.718's Avatar
P: 1,153
This may be of use: http://www.mathworks.com/help/techdo...s/braliom.html

jhae2.718 is offline
Dec2-11, 06:56 PM
PF Gold
jhae2.718's Avatar
P: 1,153

Dynamic Legend in MatLab

Actually, if I'm understanding what you want to do, I think you could get away with using sprintf and format statements as inputs to the legend and semilogy functions.

Something like:
legend(sprintf('%i legend 1', i), sprintf('%i legend 2', i), sprintf('%i legend 1', i))
It's not pretty but it should work. You can do something similar for the line types with a cell array.

Register to reply

Related Discussions
Matlab Legend Problem Math & Science Software 0
Matlab: dynamic data entry into structure Math & Science Software 6
Question about matlab figure legend. Math & Science Software 2
will you pass on the story to your son? General Discussion 6