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]
end
```

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]
end
# 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
end
res = find_zero(res, (exp10(-4), exp10(1)))
return res
end
println(w_3db(P))
```

Is there anything wrong with the built-in `dcgain`

?

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

```
dcgain(sys)[1]
```

works also fine…