FUNCTION REFERENCE

margin

Classical SISO gain and phase margins.

Classical SISO gain and phase margins.

Syntax

[Gm,Pm,Wcg,Wcp] = margin(sys)

Syntax

[Gm,Pm,Wcg,Wcp] = margin(mag,phase,w)

Gm is an absolute gain factor at the negative-real-axis crossing Wcg; Pm is degrees from -180 at the unity-magnitude crossing Wcp. Frequencies are radians per model time unit. Among multiple crossings, selects gain closest to unity on a logarithmic scale and phase closest to zero. An absent crossing returns Inf for its margin and NaN for its frequency. Model crossings are bracketed on the automatic grid and refined by bisection; data crossings interpolate log magnitude and phase against log frequency (linear frequency when the left sample is zero).

Automatic frequency starts with the 1000-point bode grid based on pole/zero scales above 1e-10 (default 0.01..100). Continuous models expand both ends to bounds for the finite nonzero gain and phase crossing frequencies, with one extra decade on each side. Models with delays also sample the

delay-induced phase turns within the bounded search grid. The expanded grid retains at least the original logarithmic density, up to 10000 points; requests exceeding this bound or representable coefficient/range limits require sampled frequency data. Discrete scales are abs(log(z))/Ts; the upper endpoint is always exactly pi/Ts, evaluated at z=-1, with at least two decades of span. A negative real H(-1) counts as a gain-margin crossing at that endpoint. Without outputs, both forms draw a Bode plot with margins in the title; multiple SISO models overlay. Data require nonnegative absolute magnitudes, unwrapped phase in degrees and strictly increasing nonnegative frequencies, all with equal length 2..10000.

Models with zero inputs or zero outputs are rejected with an error; at least one input and one output are required.

Example

G=tf(10,[1 6 11 6]); [Gm,Pm,Wcg,Wcp]=margin(G)

Example

G=tf(2,[1 1 0]); margin(G)

Differences from MATLAB: SISO only. Grid bracketing can miss tangential or closely spaced crossings; supply a denser sampled-data response when needed. The discrete Nyquist endpoint is included: for 1/(z-0.5), Gm=1.5 at pi/Ts, whereas python-control 0.10.2 returns Inf. No frequency-range options; allmargin lists every crossing.

Classifier overload: Syntax: m = margin(mdl,X,Y)

Returns true-class score minus maximal other-class score for each observation, in observation order.

Example

m=fitcknn([0;2],[1;2]); margin(m,[0;2],[1;2])

Differences from MATLAB: Custom observation weights and learner subsets are unsupported.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.