G(s)=k/s*(s+2)*(s+4)
How do you express the root locus for k in MATLAB
17 views (last 30 days)
Show older comments
How do you express the root locus for k in MATLAB

Answers (2)
Star Strider
on 8 Dec 2023
Perhaps something like this —
K = 1:3; % Define: 'K' (Vector)
s = tf('s');
H1 = @(K) (s+2) / ((s+1)*(s+K)); % Anonymous Function
H2 = 1/(s+3);
H12 = @(K) feedback(H1(K),H2); % Anonymous Function
cm = turbo(numel(K));
figure
hold on
for k1 = 1:numel(K)
sys = H12(K(k1)) % Display Transfer Function
[r{k1},k{k1}] = rlocus(sys);
hp{k1} = plot(real(r{k1}).', imag(r{k1}).', 'DisplayName',["K = "+string(K(k1))], 'Color',cm(k1,:));
hpp(k1) = hp{k1}(1);
end
hold off
grid
xlabel('Real Axis')
ylabel('Imaginary Axis')
title('Root Locus As Function Of ‘K’')
legend([hpp], 'Location','best')
xlim([-10 max(xlim)])
.
0 Comments
Paul
on 8 Dec 2023
Edited: Paul
on 8 Dec 2023
"How do you express the root locus for k"
Assuming the question is how to plot the locus of the closed loop poles as k varies, then some choices (among others) are:
a. write a loop that iterates over values of K. For each value of K form the closed loop system transfer function (feedback may be helpful) and compute its poles (pole). Collect the poles in an array and plot them after the loop completes, or plot the pole locations on each iteration of the loop. It may be difficult to "connect the dots" of the pole locations on the plot to make smooth trajectories of the loci.
Other variation of this would be to use a model array or a tunable model. But those would probably be overkill for this problem.
b. rearrange the block diagram to isolate the gain K, and compute the open loop system at K assuming K =1. This procedure can be done by hand or using tools like connect. Then use rlocus or rlocusplot on the open loop system.
0 Comments
See Also
Categories
Find more on Classical Control Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!