Bode Plot Stability Margins

Hard MATLAB Control Asked at Honeywell
Solve this problem

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.
Starter codeMATLAB
1function [gm_db, pm_deg, stable] = margins(num, den)2% TODO3end