How to determine the -3dB frequency of a system

I have the following system, controlled with a PI controller:

using ControlSystemsBase, Plots

P_sc = 4.42616018443722e6
I_sc = 11838.3957271545*4

P = tf(-1.898e-8, [1, 0.01934])
C = -pid(P_sc, I_sc)

PC = feedback(P*C)

I can create a bodeplot of the plant or the feedback system, but how can I get the -3db frequency as a number?

OK, first I need the DC gain. I use this function to determine it:

function dc_gain(sys)
     sys.matrix[1].num[0] / sys.matrix[1].den[0]

I guess this will not work for all types of systems, not sure for which it works and for which not…

OK, this code does what I want, but I would be pleased for any comments how to improve it:

using ControlSystemsBase, Roots

P = tf(-1.898e-8, [1, 0.01934])

function dc_gain(sys)
     sys.matrix[1].num[0] / sys.matrix[1].den[0]

# calculate the 3db bandwidth of a low-pass like system
function w_3db(sys)
    gain_3db = abs(dc_gain(sys)) *  exp10(-3/20)
    function res(w)
        mag = bode(sys, [w])[1][1]
        mag - gain_3db
    res = find_zero(res, (exp10(-4), exp10(1)))
    return res


Is there anything wrong with the built-in dcgain?

Nothing wrong with it, just that I did not know that it exists…


works also fine…