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: root locus

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

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -