lti_margin
Builtin index · Signal processing
result = lti_margin(sys)
Input: sys · Output: result
What it is
No chapter describes this one yet. It exists -- the name comes from the interpreter's own table -- but the prose has not been written. That is a gap in the documentation, not in the engine.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = lti_margin(sys) | sys —not documented yet | gm = 6 —15.56 dB | Returns a record {gm, gm_db, pm, w_gm, w_pm, stable} for the loop transfer function sys closed with unity negative feedback. gm: the gain margin as a factor (gm_db in dB), the amount the loop gain can be multiplied by before the closed loop reaches the stability boundary, measured at w_gm, where the phase is -180 degrees; pm: the phase margin in degrees, measured at w_pm, where the gain is 1; stable: whether the closed loop L/(1+L) is stable. A margin that does not exist (the phase never reaches -180, or the gain never reaches 1) is inf with a NaN frequency. With several crossings the smallest margin is reported. For a continuous system the crossings are roots of polynomials in w, not points of a frequency grid; for a discrete one they are found by a scan of (0, pi] refined by bisection. lti_margin(lti_tf([1], [1, 3, 2, 0])) gives gm = 6 (15.56 dB) at w_gm = sqrt(2). Single-input single-output only. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
plant = lti_tf([1], [1, 3, 2, 0]) # 1 / (s (s+1) (s+2))
m = lti_margin(plant)
print("{m.gm} at {m.w_gm} rad/s") # 6 at 1.414214 rad/s
closed = lti_feedback(lti_series(2, plant)) # gain 2, unity negative feedback
print(lti_is_stable(closed)) # true
r = lti_step(closed, 20)
print(r.y[len(r.y) - 1]) # 1.006126
d = lti_c2d(lti_tf([1], [0.5, 1]), 0.1) # first-order lag, tau = 0.5
print(d.A) # [0.818731], exp(-0.1/0.5)
output
6 at 1.414214 rad/s true 1.006126 [0.818731]
from signal-processing