Skip to content

Commit

Permalink
Fix damp according to #450 (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
albheim authored Feb 24, 2021
1 parent 1ea3b9a commit 47a7395
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ poles, `ps`, of `sys`"""
function damp(sys::LTISystem)
ps = pole(sys)
if isdiscrete(sys)
ps = log(ps)/sys.Ts
ps = log.(ps)/sys.Ts
end
Wn = abs.(ps)
order = sortperm(Wn; by=z->(abs(z), real(z), imag(z)))
Expand Down
4 changes: 4 additions & 0 deletions test/test_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ z, p, k = zpkdata(G)
@test damp(sys)[1] [1.0, 4.0, 4.0]
@test damp(sys)[2] [1.0, -1.0, 1.0]

sysd = zpk([], [0.1+0.5im, 0.1-0.5im, 0.9], 1.0, 0.01)
@test damp(sysd)[1] [10.536051565782627, 152.96671271576292, 152.96671271576292]
@test damp(sysd)[2] [1.0, 0.4403159432698576, 0.4403159432698576]

damp_output = damp(ex_11)
@test damp_output[1] [1.0, 1.0, 2.0, 2.0, 3.0]
# THe order of the poles in ±1 and ±2 may come out in different order
Expand Down

0 comments on commit 47a7395

Please sign in to comment.