how to plot number in legend ?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2018 年 4 月 6 日
Sure, just use num2str to write whatever text (if any) you want for each line label and pass to legend
採用された回答
Walter Roberson
2018 年 4 月 7 日
avals = [ 1 3 5];
for a = avals
hold on;
disp(a)
H1 = tf([ a],[3 4 ])
step(H1)
end
legend( sprintfc('%g', avals) )
I think that your legend() call in your image has the wrong order. The larger the numerator in the transfer function, the more gain there should be, so the last a drawn, the 5, should be the last legend entry, but you have reversed the order.
その他の回答 (1 件)
tomer polsky
2018 年 5 月 13 日
6 件のコメント
dpb
2018 年 5 月 14 日
編集済み: dpb
2018 年 5 月 14 日
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
2018 年 5 月 14 日
>> 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.
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!