Skip to content

Commit 95d6908

Browse files
committed
fix bug with axis limits with no asymptotes
fix bug plotting zeros when only zeros in zero exist
1 parent 01e33ea commit 95d6908

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

control/rlocus.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None, plotstr='-', Plot=True,
113113

114114
# plot open loop zeros
115115
zeros = array(nump.r)
116-
if zeros.any():
116+
if zeros.size > 0:
117117
ax.plot(real(zeros), imag(zeros), 'o')
118118

119119
# Now plot the loci
@@ -148,6 +148,9 @@ def _default_gains(num, den, xlim, ylim):
148148
mymat_xl = np.append(mymat, open_loop_zeros_xl)
149149
else:
150150
mymat_xl = mymat
151+
singular_points = np.concatenate((num.roots, den.roots), axis=0)
152+
important_points = np.concatenate((singular_points, real_break), axis=0)
153+
mymat_xl = np.append(mymat_xl, important_points)
151154

152155
if xlim is None:
153156
x_tolerance = 0.05 * (np.max(np.max(np.real(mymat_xl))) - np.min(np.min(np.real(mymat_xl))))
@@ -223,10 +226,8 @@ def _k_max(num, den, real_break_points, k_break_points):
223226
farthest_points = asymp_center + distance_max * np.exp(asymp_angles * 1j) # farthest points over asymptotes
224227
kmax_asymp = -den(farthest_points) / num(farthest_points)
225228
else:
226-
farthest_points = 2 * np.max(np.abs(important_points))
227-
kmax_asymp = [-den(farthest_points) / num(farthest_points)]
228-
if np.max(kmax_asymp) == 0:
229229
kmax_asymp = [den.coeffs[0] / num.coeffs[0] * 3]
230+
230231
kmax = np.max(np.concatenate((np.real(kmax_asymp), k_break_points), axis=0))
231232
return kmax
232233

0 commit comments

Comments
 (0)