Bode Plot Stability Margins
Compute the gain and phase margins of a control loop from its open-loop transfer function and decide whether the closed loop is stable.
Constraints
- Function: [gm_db, pm_deg, stable] = margins(num, den).
- Gain margin in decibels, phase margin in degrees.
- Use margin on a tf object.
- Treat an infinite gain margin as stable in that respect.
- A system with no gain crossover must not error.
- Return stable as a logical.
1function [gm_db, pm_deg, stable] = margins(num, den)2% TODO3end