for loop - matlab, how to plot the "root locus" -
given function (call sys(s)), can use matlab: rlocus(sys) plot root locus of function.
however,if given function parameter (say b), eg sys(s)=(2s+2+b)/s , how can use matlab plot rlocus(sys) function of parameter b?
let's b changes between 1 , 100 intervals of 1.
b = 1:100; we need create axes , hold them, can plot root loci on top of each other.
axes(); hold('on'); now need create transfer function each b , plot root locus.
for idx = 1:length(b) sys = tf([2 2+b(idx)], [1 0]); rlocus(sys); end this resulting plot: 
i not find vectorized solution, takes quite long time. took 45 seconds on computer. if need calculate many values, need vectorized solution.
to add legend, need create cell array store b values.
legendstr = cell(1, length(b)); then, inside loop need convert b values string , store them in legendstr.
legendstr{idx} = num2str(b(idx)); after loop add legend plot.
legend(legendstr)
Comments
Post a Comment