MATLAB Answers

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

조회 수: 17(최근 30일)
Mohamad Balawi
Mohamad Balawi 2021년 8월 27일
댓글: Mohamad Balawi 2021년 8월 27일
For example when I use the following code to plot root locus:
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.

채택된 답변

Adam Danz
Adam Danz 2021년 8월 27일
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.
% 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
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')

추가 답변(0개)




Community Treasure Hunt

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

Start Hunting!

Translated by