Skip to content

Commit f309232

Browse files
committed
still imperfect
1 parent 7eefe8b commit f309232

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

control/margins.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,18 @@ def dstab(w):
223223
[ sp.optimize.brentq(arg, sys.omega[i], sys.omega[i+1])
224224
for i in widx if i+1 < len(sys.omega) ])
225225

226+
# find all stab margins?
227+
widx = np.where(np.diff(np.sign(np.diff(dstab(sys.omega)))))[0]
228+
wstab = np.array(
229+
[ sp.optimize.minimize_scalar(
230+
dstab, bracket=(sys.omega[i], sys.omega[i+1]))
231+
for i in widx if i+1 < len(sys.omega) and
232+
np.diff(np.diff(dstab(sys.omega[i-1:i+2])))[0] < 0 ])
233+
226234
# there is really only one stab margin; the closest
227-
res = sp.optimize.minimize_scalar(
228-
dstab, bracket=(sys.omega[0], sys.omega[-1]))
229-
wstab = np.array([res.x])
235+
#res = sp.optimize.minimize_scalar(
236+
# dstab, bracket=(sys.omega[0], sys.omega[-1]))
237+
#wstab = np.array([res.x])
230238

231239
# margins, as iterables, converted frdata and xferfcn calculations to
232240
# vector for this

0 commit comments

Comments
 (0)