From 5e6a7ebf636d11a71e92883abc366e094f48e599 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Sat, 21 Aug 2021 08:03:35 +0200 Subject: [PATCH 1/2] optional epsilon in dcgain --- src/analysis.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index 9b2a31931..1f10aaabd 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -89,13 +89,17 @@ function det(sys::Matrix{S}) where {S<:SisoZpk} end """ - dcgain(sys) + dcgain(sys, ϵ=0) Compute the dcgain of system `sys`. -equal to G(0) for continuous-time systems and G(1) for discrete-time systems.""" -function dcgain(sys::LTISystem) - return iscontinuous(sys) ? evalfr(sys, 0) : evalfr(sys, 1) +equal to G(0) for continuous-time systems and G(1) for discrete-time systems. + +`ϵ` can be provided to evaluate the dcgain at a small +non-zero frequency. +""" +function dcgain(sys::LTISystem, ϵ=0) + return iscontinuous(sys) ? evalfr(sys, -ϵ) : evalfr(sys, 1-ϵ) end """ From 365ec83fa51484b8554d17d6d377d88c349fc655 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Sat, 21 Aug 2021 08:24:51 +0200 Subject: [PATCH 2/2] Update analysis.jl --- src/analysis.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index 1f10aaabd..d286d644b 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -95,11 +95,11 @@ Compute the dcgain of system `sys`. equal to G(0) for continuous-time systems and G(1) for discrete-time systems. -`ϵ` can be provided to evaluate the dcgain at a small -non-zero frequency. +`ϵ` can be provided to evaluate the dcgain with a small perturbation into +the stability region of the complex plane. """ function dcgain(sys::LTISystem, ϵ=0) - return iscontinuous(sys) ? evalfr(sys, -ϵ) : evalfr(sys, 1-ϵ) + return iscontinuous(sys) ? evalfr(sys, -ϵ) : evalfr(sys, exp(-ϵ*G.Ts)) end """