Why is the margin() function returning NaN?

I have the following linear state space system for 8 m/s wind:

julia> @time include("mwes/mwe_06.jl")
StateSpace{Continuous, Float64}
A = 
 0.0     0.0                  0.217328
 0.0  -142.50000000000003    -0.16245000000000004
 0.0     0.0               -135.5115580754543
B = 
     0.0
     0.0
 77363.88168172735
C = 
 0.125  0.5  0.000608
D = 
 0.0

Continuous-time state-space model

Why does the function margin return NaN`

[ Info: Gain margin: [NaN;;], Phase margin: [Inf;;], Gain crossover frequency: [14.923313891148691;;], Phase crossover frequency: [85.15256672572397;;]
StateSpace{Continuous, Float64}

The bode plot looks like this (this are two plots in one, one for 8 and one for 9 m/s wind)

Gain margin is the gain at the frequency where your system crosses -180 degree. If your system never reaches that point, what result do you expect?

1 Like

Please note, your printout

[ Info: Gain margin: [NaN;;], Phase margin: [Inf;;], Gain crossover frequency: [14.923313891148691;;], Phase crossover frequency: [85.15256672572397;;]

is wrong, the phase margin is not Inf, you have confused phase margin and one of the frequencies

julia> margin(sys)
(wgm = [NaN;;], gm = [Inf;;], wpm = [16.691123499256943;;], pm = [80.97336203179722;;])

The function diskmargin from RobustAndOptimalControl gives a better output:

julia> diskmargin(sys)
Disk margin with:
Margin: 1.6377470230519808
Frequency: 27.113978155105443 rad/s,  4.3153236502707 Hz
Gain margins: [0.09958168466703816, 10.042007256089361]
Phase margin: 78.62627648625572
Delay margin: 0.050611806036664694 s
Skew: 0
Worst-case perturbation: 0.41321232142013375 - 1.7377816567466957im

But shouldn’t the function margin also work?

I understand the gain margins and phase and delay margin. But what is the meaning of “Margin: 1.63…” here?

The diskmargins are defined differently, the traditional gain margin is truly not defined here so there is no problem with the output of the margin function.

This is the diskmargin from which the other numbers are derived. See the paper cited in the docstring if you want to learn more.

1 Like

Thank you so much!