how to plot number in legend ?
Mostrar comentarios más antiguos
he this is my code
for a=[ 1 3 5]
hold on;
disp('a')
H1=tf([ a],[3 4 ])
step(H1)
end
I want that in the plot it will be written the value of a of each line in the legend is it possible ?
2 comentarios
dpb
el 6 de Abr. de 2018
Sure, just use num2str to write whatever text (if any) you want for each line label and pass to legend
tomer polsky
el 7 de Abr. de 2018
Editada: tomer polsky
el 7 de Abr. de 2018
Respuesta aceptada
Más respuestas (1)
tomer polsky
el 13 de Mayo de 2018
0 votos
6 comentarios
Walter Roberson
el 13 de Mayo de 2018
legend( sprintfc('K=%g', avals) )
tomer polsky
el 14 de Mayo de 2018
dpb
el 14 de Mayo de 2018
color is independent of the string; that's based on the color spec of the line that your string refers to; it's a 1:1 correlation to those objects in the axes in their created order up to the number of labels passed; if the linestyle you want in the legend is the desired one, you've got to use the optional handle/subject argument to specify which one you mean.
Walter Roberson
el 14 de Mayo de 2018
However, when you step() a tf, the legend string is created in odd ways; there does not appear to be much control over it.
Hmmm....didn't notice but presumed tf something else as at least here
>> for a=[ 1 3 5]
hold on;
disp('a')
H1=tf([ a],[3 4 ])
step(H1)
end
a
Undefined function 'tf' for input arguments of type 'double'.
>>
the xfr-function requires a digital filter object for input, not a double so OP may have something else of same name or older release or...???
>> which tf -all
C:\ML_R2017\toolbox\signal\signal\@dfilt\tf.m % dfilt method
>>
Must admit haven't used it ever, though, since like R12 or thereabouts as gave up the consulting gig way back when so need went away...oldest release still at hand is R2014b and it's same need.
So, to OP--what is tf and what does step do to it??? I can't run what you have here to 'spearmint with--
Walter Roberson
el 14 de Mayo de 2018
>> which tf(1)
/Applications/MATLAB_R2018a.app/toolbox/control/ctrlmodels/@tf/tf.m % tf constructor
tf() is one of the primary routines for building transfer functions for control systems. step() with no output causes plotting of the transfer function.
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!