diff --git a/src/freqresp.jl b/src/freqresp.jl index f8c034cbc..56cce3034 100644 --- a/src/freqresp.jl +++ b/src/freqresp.jl @@ -1,24 +1,24 @@ -"""sys_fr = freqresp(sys, w) +""" freqresp(G, Ω) -> G_fr -Evaluate the frequency response of a linear system - -`w -> C*((iw*im -A)^-1)*B + D` - -of system `sys` over the frequency vector `w`.""" -@autovec () function freqresp(sys::LTISystem, w_vec::AbstractVector{<:Real}) +Evaluate the frequency response of the linear system `G` at frequencies `Ω`. +(for a discrete-system with sample time `Ts` the frequency repsonse is evaluated in +points `exp.(Ω*(im*Ts))` on the unit circle. +""" +@autovec () function freqresp(G::LTISystem, Ω::AbstractVector{<:Real}) # Create imaginary freq vector s - if iscontinuous(sys) - s_vec = im*w_vec + if iscontinuous(G) + s_vec = im*Ω else - s_vec = exp.(w_vec*(im*sys.Ts)) + s_vec = exp.(Ω*(im*G.Ts)) end - #if isa(sys, StateSpace) - # sys = _preprocess_for_freqresp(sys) + #if isa(G, StateSpace) + # G = _preprocess_for_freqresp(G) #end - ny,nu = noutputs(sys), ninputs(sys) - [evalfr(sys[i,j], s)[] for s in s_vec, i in 1:ny, j in 1:nu] + ny, nu = size(G) + [evalfr(G[i,j], s)[] for s in s_vec, i in 1:ny, j in 1:nu] end + # Implements algorithm found in: # Laub, A.J., "Efficient Multivariable Frequency Response Computations", # IEEE Transactions on Automatic Control, AC-26 (1981), pp. 407-408.