Clear Filters
Clear Filters

Show value on the root locus plot without using the Data Cursor

26 views (last 30 days)
There are a large number of examples how to plot the root locus - using the rlocus function. The gain K can be showed from the graph with the Data Cursor. Is there anyway to show this value without using the Data Cursor but Matlab Code.
For example, I want to show Poles, Damping, Overshoot%, Frequency if K = 10 on the plot using Matlab code?

Accepted Answer

Jonathan LeSage
Jonathan LeSage on 15 Oct 2013
The rlocus function can output the complex root locations and the corresponding gains. You can manually plot these values to replicate the plot generated by rlocus and then plot particular points of interest, such as the complex roots when K = 10.
You can also use the stepinfo function to acquire additional information, such as percent overshoot, to display. Using a method of this variety allows you to have full control over what you are displaying on your root locus plot!
Here is some code to get you started, and to introduce you to useful functions:
% Specify an arbitrary transfer function
G = tf([1 2],[1 4 13]);
% Pick gain to mark on root locus
gainToMark = 5;
% The rlocus function can output the values normally plotted and the gains
% associated with each value on the complex plane
[complexVec,gainsVec] = rlocus(G);
% Recall: the root locus is displayed on the complex plane (s = \sigma +
% j*\omega)
realPart = real(complexVec);
imagPart = imag(complexVec);
% First closed loop pole with increasing gain, K
realCLpole1 = realPart(1,:);
imagCLpole1 = imagPart(1,:);
% Second closed loop pole with increasing gain, K
realCLpole2 = realPart(2,:);
imagCLpole2 = imagPart(2,:);
% Plot the closed loop poles as varying with gain K
hold on;
ylabel('Imaginary Axis');
xlabel('Real Axis');
% Plot open loop poles
plot(realCLpole1(1),imagCLpole1(1),'bx'); hold on;
% Plot open loop zeros
plot(realCLpole1(end),imagCLpole1(end),'bo'); hold on;
% Find the the location of the gain of interest on the root locus
indexOfGain = find(gainsVec >= gainToMark,1,'first');
markedGain = gainsVec(indexOfGain);
% Form the closed-loop feedback system with selected gain
CLsystem = feedback(G,markedGain);
% Acquire step response values of interest from the closed-loop system
stepResponse = stepinfo(CLsystem);
percentOvershoot = stepResponse.Overshoot;
% Plot test box with results onto plot
gainString = ['Gain: ' num2str(markedGain)];
osString = ['%OS: ' num2str(percentOvershoot) ' %'];
% Plot closed-loop poles arising from feedback gain selection
xlim([-10 2]); ylim([-4 4]);
Hope this helps!

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!