MATLAB Answers

How to find the intersection a root locus plot and a line with specific angle?

22 views (last 30 days)
For example when I use the following code to plot root locus:
s=tf('s');
GH=(1)/(s*(s+1)^2);
rlocus(GH)
the output is:
But i'm interested in the intercection between a 60 degree line and the plot, the wanted output is the following:
I'm interested in the value of K.

Accepted Answer

Adam Danz
Adam Danz on 27 Aug 2021
There may be an analytical approach that would be better than this approach but one way to do it is to get the handle of the blue line (assuming there is only 1 blue line in the axes and the line is truely blue, [0 0 1]) and to compute the intersection of that line and the line defined by your angle from (0,0). This uses intersections.m from the file exchange.
clf
s=tf('s');
GH=(1)/(s*(s+1)^2);
rlocus(GH)
% Get handle to blue line
ax = gca();
curveLine = findobj(ax, 'Type','Line','Color', 'b', 'Marker','none');
% Find intersection of the angle from x-axis at
% origin (0,0)
ang = 60; % deg from negative x-axis into quadrant 3
xLine = [0, ax.XLim(1)];
yLine = [0, tand(-ang)*xLine(2)];
[x0,y0,~,~] = intersections(curveLine.XData, curveLine.YData, xLine, yLine);
% Plot the lines and intersection
hold(ax,'on')
plot(ax, curveLine.XData, curveLine.YData, 'k--', 'LineWidth', 2)
plot(ax, xLine, yLine, 'k--', 'LineWidth', 2)
% remove (0,0) intersection and label intersection
isNot0 = x0~=0 & y0~=0;
plot(ax, x0(isNot0), y0(isNot0), 'mo','MarkerSize', 12)
text(ax, x0(isNot0)*2, y0(isNot0), ...
sprintf('%.1f%s (%.3f, %.3f)',ang,char(186),x0(isNot0), y0(isNot0)), ...
'HorizontalAlignment', 'right')

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by