From 11fa006cc8733dd9333d21ebac8491b80d924074 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Wed, 29 Sep 2021 15:37:29 +0200 Subject: [PATCH] bugfix dcgain --- src/analysis.jl | 2 +- test/test_analysis.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/analysis.jl b/src/analysis.jl index 3edc17c3c..909ebe96e 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -99,7 +99,7 @@ equal to G(0) for continuous-time systems and G(1) for discrete-time systems. the stability region of the complex plane. """ function dcgain(sys::LTISystem, ϵ=0) - return iscontinuous(sys) ? evalfr(sys, -ϵ) : evalfr(sys, exp(-ϵ*G.Ts)) + return iscontinuous(sys) ? evalfr(sys, -ϵ) : evalfr(sys, exp(-ϵ*sys.Ts)) end """ diff --git a/test/test_analysis.jl b/test/test_analysis.jl index 676cfa316..3e2bd2c9c 100644 --- a/test/test_analysis.jl +++ b/test/test_analysis.jl @@ -150,6 +150,8 @@ z, p, k = zpkdata(G) ## GAIN ## #Gain is confusing when referring to zpkdata. Test dcgain instead @test [dcgain(H[1, 1]) dcgain(H[1, 2]); dcgain(H[2, 1]) dcgain(H[2, 2])] ≈ [0 0; 0.2 1/3] @test [dcgain(G[1, 1]) dcgain(G[1, 2]); dcgain(G[2, 1]) dcgain(G[2, 2])] ≈ [0 0; 0.2 1/3] +@test dcgain(H[1, 1], 1e-6)[] == 0 +@test dcgain(H[2, 1], 1e-6)[] ≈ 0.2 rtol=1e-5 ## MARKOVPARAM ## @test markovparam(G, 0) == [0.0 0.0; 1.0 0.0]