Home > Archive > Matlab > December 2006 > How to manage the legend
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to manage the legend
|
|
| Luca D. 2006-12-27, 8:17 am |
| I need to trace different bode diagrams in the same figure, and I'd
like to add a voice in the legend each time I draw something.
Example, if I do:
figure('Name', 'Bode diagrams');
bode(A), hold on;
bode(B);
bode(C);
legend('A', 'B', 'C');
it works, but since I do lots of bode() calls, I'd like to do:
figure('Name', 'Bode diagrams');
bode(A), hold on, legend('A');
bode(B), legend('B');
bode(C), legend('C');
but it doesn't work, it just shows the last legend() call;
Thank you.
| |
|
| Luca D.:
<SNIP a legend-fiend...
one of the solutions
% assuming you own the <control system tbx>
nb=4;
sleg=cell(nb,1);
hold on;
for i=1:nb
bode(tf([i,(i+1)/10],1:(i+1)));
sleg{i,1}=sprintf('bode #%-1d',i);
end
legend(sleg);
us
| |
| Luca D. 2006-12-27, 7:09 pm |
| us ha scritto:
> one of the solutions
>
> % assuming you own the <control system tbx>
> nb=4;
> sleg=cell(nb,1);
> hold on;
> for i=1:nb
> bode(tf([i,(i+1)/10],1:(i+1)));
> sleg{i,1}=sprintf('bode #%-1d',i);
> end
> legend(sleg);
Oh.. thanks for your answer.
I hoped there was a simpler solution, something like 'hold on' for
legends..
|
|
|
|
|